From 33c737718c0ff7a02739e8c7c2a1e026d17d0ec0 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 3 Oct 2024 17:01:24 +0200 Subject: [PATCH 01/52] [java] UnitTestShouldUseBeforeAnnotation: Consider JUnit 5 and TestNG --- docs/pages/release_notes.md | 3 + .../resources/category/java/bestpractices.xml | 28 ++- .../xml/UnitTestShouldUseBeforeAnnotation.xml | 213 +++++++++++------- 3 files changed, 159 insertions(+), 85 deletions(-) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 0068c0480d..645aa4f485 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -16,6 +16,9 @@ This is a {{ site.pmd.release_type }} release. ### 🌟 Rule Changes +#### Changed Rules +* {% rule java/bestpractices/UnitTestShouldUseBeforeAnnotation %} (Java Best Practices) now also considers JUnit 5 and TestNG tests. + #### 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. diff --git a/pmd-java/src/main/resources/category/java/bestpractices.xml b/pmd-java/src/main/resources/category/java/bestpractices.xml index 2698fbab73..6786399cea 100644 --- a/pmd-java/src/main/resources/category/java/bestpractices.xml +++ b/pmd-java/src/main/resources/category/java/bestpractices.xml @@ -1342,16 +1342,20 @@ public class MyTest2 { - This rule detects methods called `setUp()` that are not properly annotated as a setup method. - This is primarily intended to assist in upgrading from JUnit 3, where setup methods were required to be called `setUp()`. - To a lesser extent, this may help detect omissions even under newer JUnit versions, as long as you are following this convention to name the methods. +This rule detects methods called `setUp()` that are not properly annotated as a setup method. +This is primarily intended to assist in upgrading from JUnit 3, where setup methods were required to be called `setUp()`. +To a lesser extent, this may help detect omissions even under newer JUnit versions or under TestNG, +as long as you are following this convention to name the methods. - JUnit 4 will only execute methods annotated with `@Before` before all tests. - JUnit 5 introduced `@BeforeEach` and `@BeforeAll` annotations to execute methods before each test or before all tests in the class, respectively. +* JUnit 4 will only execute methods annotated with `@Before` before all tests. +* JUnit 5 introduced `@BeforeEach` and `@BeforeAll` annotations to execute methods before each test or before all + tests in the class, respectively. +* TestNG provides the annotations `@BeforeMethod` and `@BeforeClass` to execute methods before each test or before + tests in the class, respectively. 3 @@ -1363,9 +1367,15 @@ public class MyTest2 { pmd-java:typeIs('org.junit.Before') or pmd-java:typeIs('org.junit.jupiter.api.BeforeEach') or pmd-java:typeIs('org.junit.jupiter.api.BeforeAll') - or pmd-java:typeIs('org.testng.annotations.BeforeMethod')])] - (: Make sure this is a junit 4 class :) - [../MethodDeclaration[pmd-java:hasAnnotation('org.junit.Test')]] + or pmd-java:typeIs('org.testng.annotations.BeforeMethod') + or pmd-java:typeIs('org.testng.annotations.BeforeClass') + ])] + (: Make sure this is a JUnit 4/5 or TestNG class :) + [../MethodDeclaration[ + pmd-java:hasAnnotation('org.junit.Test') + or pmd-java:hasAnnotation('org.junit.jupiter.api.Test') + or pmd-java:hasAnnotation('org.testng.annotations.Test') + ]] ]]> diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/UnitTestShouldUseBeforeAnnotation.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/UnitTestShouldUseBeforeAnnotation.xml index 10d6fbc524..d9ae22cfd4 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/UnitTestShouldUseBeforeAnnotation.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/UnitTestShouldUseBeforeAnnotation.xml @@ -5,8 +5,9 @@ xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests http://pmd.sourceforge.net/rule-tests_1_0_0.xsd"> - Contains setUp + JUnit4 Test class contains setUp 1 + 3 - Contains @setUp + JUnit4 Test class with Before is ok 0 - Renamed setup + JUnit4 Test class with renamed setup using Before is ok 0 - #1446 False positive with JUnit4TestShouldUseBeforeAnnotation when TestNG is used + Contains setUp, not a JUnit 4/5/TestNG test 0 + + + + JUnit4 Test class contains setUp with different signature is ok + 0 + - - - - #940 False positive with JUnit4TestShouldUseBeforeAnnotation when JUnit5's 'BeforeEach' is used - 0 - - - - - #940 False positive with JUnit4TestShouldUseBeforeAnnotation when JUnit5's 'BeforeAll' is used - 0 - - - - Contains setUp, not a junit 4 test - 0 - - - - Contains setUp with different signature - 0 - +]]> @@ -173,4 +118,120 @@ public class AReallyCoolFeatureTest extends BaseTest { } ]]> + + + TestNG class contains setUp + 1 + 4 + + + + + TestNG class contains setUp with different signature is ok (#1446) + 0 + + + + + TestNG with @BeforeMethod is ok (#1446) + 0 + + + + + TestNG with @BeforeClass is ok + 0 + + + + + JUnit5 Test class contains setUp + 1 + 4 + + + + + JUnit5 Test class with BeforeEach is ok (#940) + 0 + + + + + JUnit5 Test class with BeforeAll is ok (#940) + 0 + + From 9337e5a7a21428f92d270c9309b141754e8b7f39 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 3 Oct 2024 17:18:04 +0200 Subject: [PATCH 02/52] [java] UnitTestShouldUseAfterAnnotation: Consider JUnit 5 and TestNG --- docs/pages/release_notes.md | 1 + .../resources/category/java/bestpractices.xml | 32 ++- .../xml/UnitTestShouldUseAfterAnnotation.xml | 227 +++++++++++------- 3 files changed, 163 insertions(+), 97 deletions(-) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 645aa4f485..d5d1238fcc 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -17,6 +17,7 @@ This is a {{ site.pmd.release_type }} release. ### 🌟 Rule Changes #### Changed Rules +* {% 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. #### Renamed Rules diff --git a/pmd-java/src/main/resources/category/java/bestpractices.xml b/pmd-java/src/main/resources/category/java/bestpractices.xml index 6786399cea..cd51508131 100644 --- a/pmd-java/src/main/resources/category/java/bestpractices.xml +++ b/pmd-java/src/main/resources/category/java/bestpractices.xml @@ -1295,36 +1295,46 @@ public class MyTestCase { - This rule detects methods called `tearDown()` that are not properly annotated as a cleanup method. - This is primarily intended to assist in upgrading from JUnit 3, where tear down methods were required to be called `tearDown()`. - To a lesser extent, this may help detect omissions under newer JUnit versions, as long as you are following this convention to name the methods. +This rule detects methods called `tearDown()` that are not properly annotated as a cleanup method. +This is primarily intended to assist in upgrading from JUnit 3, where tear down methods were required to be called `tearDown()`. +To a lesser extent, this may help detect omissions even under newer JUnit versions or under TestNG, +as long as you are following this convention to name the methods. - JUnit 4 will only execute methods annotated with `@After` after running each test. - JUnit 5 introduced `@AfterEach` and `@AfterAll` annotations to execute methods after each test or after all tests in the class, respectively. +* JUnit 4 will only execute methods annotated with `@After` after running each test. +* JUnit 5 introduced `@AfterEach` and `@AfterAll` annotations to execute methods after each test or after + all tests in the class, respectively. +* TestNG provides the annotations `@AfterMethod` and `@AfterClass` to execute methods after each test or after + tests in the class, respectively. 3 - - - Contains tearDown + JUnit4 test class contains tearDown 1 + 3 - Contains @After tearDown + JUnit4 test class contains tearDown with different signature is ok + 0 + + + + + JUnit4 test class contains @After tearDown is ok 0 - Renamed tearDown + JUnit4 test class contains renamed tearDown is ok 0 - #1446 False positive with JUnit4TestShouldUseBeforeAnnotation when TestNG is used - 0 - - - - - #940 False positive with JUnit4TestShouldUseAfterAnnotation when JUnit5's 'AfterEach' is used - 0 - - - - - #940 False positive with JUnit4TestShouldUseAfterAnnotation when JUnit5's 'AfterAll' is used - 0 - - - - Contains tearDown, not a junit 4 test + Contains tearDown, not a JUnit 4/5 or TestNG test is ok 0 - - - Contains tearDown with different signature - 0 - @@ -151,4 +91,119 @@ public class AReallyCoolFeatureTest extends BaseTest { } ]]> + + + TestNG test contains tearDown + 1 + 4 + + + + + TestNG test contains tearDown with different signature is ok (#1446) + 0 + + + + + TestNG test contains tearDown with @AfterMethod is ok + 0 + + + + + TestNG test contains tearDown with @AfterClass is ok + 0 + + + + + JUnit 5 test class contains tearDown + 1 + 4 + + + + + JUnit 5 test class contains tearDown with @AfterEach is ok (#940) + 0 + + + + + JUnit 5 test class contains tearDown with @AfterAll is ok (#940) + 0 + + From 0c858b0a7bbbc051e428f7760701d736af592fdf Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 4 Oct 2024 16:03:21 +0200 Subject: [PATCH 03/52] [java] SwitchStmtsShouldHaveDefault should ignore patterns Fixes #4813 --- docs/pages/release_notes.md | 2 + .../resources/category/java/bestpractices.xml | 6 ++ .../xml/SwitchStmtsShouldHaveDefault.xml | 75 +++++++++++++++++++ 3 files changed, 83 insertions(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 197b7a4aec..154ac73a28 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -32,6 +32,8 @@ The old rule names still work but are deprecated. ### 🐛 Fixed Issues * java * [#4532](https://github.com/pmd/pmd/issues/4532): \[java] Rule misnomer for JUnit* rules +* java-bestpractices + * [#4813](https://github.com/pmd/pmd/issues/4813): \[java] SwitchStmtsShouldHaveDefault false positive with pattern matching * java-errorprone * [#5067](https://github.com/pmd/pmd/issues/5067): \[java] CloseResource: False positive for FileSystems.getDefault() diff --git a/pmd-java/src/main/resources/category/java/bestpractices.xml b/pmd-java/src/main/resources/category/java/bestpractices.xml index 03b23ad1ca..aa965d9f67 100644 --- a/pmd-java/src/main/resources/category/java/bestpractices.xml +++ b/pmd-java/src/main/resources/category/java/bestpractices.xml @@ -1168,12 +1168,18 @@ class SomeTestClass { easier to follow. This can be achieved by adding a `default` case, or, if the switch is on an enum type, by ensuring there is one switch branch for each enum constant. + + This rule doesn't consider Switch Statements, that use Pattern Matching, since for these the + compiler already ensures that all cases are covered. The same is true for Switch Expressions, + which are also not considered by this rule. 3 diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/SwitchStmtsShouldHaveDefault.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/SwitchStmtsShouldHaveDefault.xml index 758b97b43b..e28cfe5b9d 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/SwitchStmtsShouldHaveDefault.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/SwitchStmtsShouldHaveDefault.xml @@ -240,4 +240,79 @@ public enum GradeSystem { } ]]> + + + [java] SwitchStmtsShouldHaveDefault false positive with pattern matching #4813 + 0 + System.out.println("WARNING " + failure.message()); + case Success success -> System.out.println(success.message()); + } + } + public void test2(AcceptableResult result) { + switch (result) { + case ProviderWarning failure: System.out.println("Provider WARNING " + failure.message()); break; + case Warning failure: System.out.println("WARNING " + failure.message()); break; + case Success success: System.out.println(success.message()); break; + } + } + public void test3(AcceptableResult result) { + switch (result) { + case ProviderWarning failure -> System.out.println("Provider WARNING " + failure.message()); + case Success success -> System.out.println(success.message()); + default -> System.out.println("default case"); + } + } +} +]]> + + + + [java] SwitchStmtsShouldHaveDefault false positive with pattern matching #4813, example 2 + 0 + { return 1; } + case C c -> { return 2; } + case D d -> { return 3; } + // case B b -> { return 4; } // not explicitly necessary, but possible + } + } +} +]]> + From e5ff5532d4edc85e8662755369de500c10f5862b Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 4 Oct 2024 16:03:43 +0200 Subject: [PATCH 04/52] Update @emouty as a contributor --- .all-contributorsrc | 3 ++- docs/pages/pmd/projectdocs/credits.md | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 28d946f30a..98aa4e2daa 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -7453,7 +7453,8 @@ "avatar_url": "https://avatars.githubusercontent.com/u/16755668?v=4", "profile": "https://github.com/emouty", "contributions": [ - "code" + "code", + "bug" ] }, { diff --git a/docs/pages/pmd/projectdocs/credits.md b/docs/pages/pmd/projectdocs/credits.md index 4795947746..77e7d0e94a 100644 --- a/docs/pages/pmd/projectdocs/credits.md +++ b/docs/pages/pmd/projectdocs/credits.md @@ -916,7 +916,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d emersonmoura
emersonmoura

🐛 - emouty
emouty

💻 + emouty
emouty

💻 🐛 eugenepugach
eugenepugach

🐛 fairy
fairy

🐛 filiprafalowicz
filiprafalowicz

💻 From 312d8e46aef97e7514e71ec30f43808baabd322e Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 4 Oct 2024 16:45:29 +0200 Subject: [PATCH 05/52] [java] ImplicitSwitchFallThrough should consider switch expressions Fixes #3362 --- docs/pages/release_notes.md | 1 + .../ImplicitSwitchFallThroughRule.java | 28 +++++++++++++------ .../xml/ImplicitSwitchFallThrough.xml | 20 +++++++++++++ 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 197b7a4aec..ea9d2b2f32 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -33,6 +33,7 @@ The old rule names still work but are deprecated. * java * [#4532](https://github.com/pmd/pmd/issues/4532): \[java] Rule misnomer for JUnit* rules * java-errorprone + * [#3362](https://github.com/pmd/pmd/issues/3362): \[java] ImplicitSwitchFallThrough should consider switch expressions * [#5067](https://github.com/pmd/pmd/issues/5067): \[java] CloseResource: False positive for FileSystems.getDefault() ### 🚨 API Changes diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/ImplicitSwitchFallThroughRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/ImplicitSwitchFallThroughRule.java index 29d91c111c..fb0a9298f5 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/ImplicitSwitchFallThroughRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/ImplicitSwitchFallThroughRule.java @@ -9,28 +9,40 @@ import java.util.regex.Pattern; import net.sourceforge.pmd.lang.ast.GenericToken; import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken; import net.sourceforge.pmd.lang.java.ast.ASTSwitchBranch; +import net.sourceforge.pmd.lang.java.ast.ASTSwitchExpression; import net.sourceforge.pmd.lang.java.ast.ASTSwitchFallthroughBranch; +import net.sourceforge.pmd.lang.java.ast.ASTSwitchLike; import net.sourceforge.pmd.lang.java.ast.ASTSwitchStatement; import net.sourceforge.pmd.lang.java.ast.JavaNode; import net.sourceforge.pmd.lang.java.ast.internal.JavaAstUtils; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule; import net.sourceforge.pmd.lang.java.rule.internal.DataflowPass; import net.sourceforge.pmd.lang.java.rule.internal.DataflowPass.DataflowResult; +import net.sourceforge.pmd.reporting.RuleContext; import net.sourceforge.pmd.util.OptionalBool; public class ImplicitSwitchFallThroughRule extends AbstractJavaRulechainRule { - //todo should consider switch exprs - private static final Pattern IGNORED_COMMENT = Pattern.compile("/[/*].*\\bfalls?[ -]?thr(ough|u)\\b.*", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); public ImplicitSwitchFallThroughRule() { - super(ASTSwitchStatement.class); + super(ASTSwitchStatement.class, ASTSwitchExpression.class); } @Override public Object visit(ASTSwitchStatement node, Object data) { + checkSwitchLike(node, asCtx(data)); + return null; + } + + @Override + public Object visit(ASTSwitchExpression node, Object data) { + checkSwitchLike(node, asCtx(data)); + return null; + } + + private void checkSwitchLike(ASTSwitchLike node, RuleContext ruleContext) { DataflowResult dataflow = DataflowPass.getDataflowResult(node.getRoot()); for (ASTSwitchBranch branch : node.getBranches()) { @@ -38,15 +50,14 @@ public class ImplicitSwitchFallThroughRule extends AbstractJavaRulechainRule { ASTSwitchFallthroughBranch fallthrough = (ASTSwitchFallthroughBranch) branch; OptionalBool bool = dataflow.switchBranchFallsThrough(branch); if (bool != OptionalBool.NO - && fallthrough.getStatements().nonEmpty() - && !nextBranchHasComment(branch)) { - asCtx(data).addViolation(branch.getNextBranch().getLabel()); + && fallthrough.getStatements().nonEmpty() + && !nextBranchHasComment(branch)) { + ruleContext.addViolation(branch.getNextBranch().getLabel()); } } else { - return null; + return; } } - return null; } boolean nextBranchHasComment(ASTSwitchBranch branch) { @@ -62,5 +73,4 @@ public class ImplicitSwitchFallThroughRule extends AbstractJavaRulechainRule { } return false; } - } diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/ImplicitSwitchFallThrough.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/ImplicitSwitchFallThrough.xml index 6d86131b0d..0ddd50e522 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/ImplicitSwitchFallThrough.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/ImplicitSwitchFallThrough.xml @@ -581,4 +581,24 @@ public class Test { } ]]> + + + switch expression with one case, which is not empty + 1 + 6 + + From 49deb8d4a03215295a45cc3cc8a76dde3b87aac9 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 4 Oct 2024 17:12:29 +0200 Subject: [PATCH 06/52] [java] SwitchDensity false positive with pattern matching Fixes #5030 --- docs/pages/release_notes.md | 2 ++ .../pmd/lang/java/ast/ASTSwitchLabel.java | 13 ++++++++-- .../java/rule/design/SwitchDensityRule.java | 2 +- .../java/rule/design/xml/SwitchDensity.xml | 26 +++++++++++++++++++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 197b7a4aec..2ce3f37529 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -32,6 +32,8 @@ The old rule names still work but are deprecated. ### 🐛 Fixed Issues * java * [#4532](https://github.com/pmd/pmd/issues/4532): \[java] Rule misnomer for JUnit* rules +* java-design + * [#5030](https://github.com/pmd/pmd/issues/5030): \[java] SwitchDensity false positive with pattern matching * java-errorprone * [#5067](https://github.com/pmd/pmd/issues/5067): \[java] CloseResource: False positive for FileSystems.getDefault() diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTSwitchLabel.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTSwitchLabel.java index 8391284ec8..2b489d4fde 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTSwitchLabel.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTSwitchLabel.java @@ -50,8 +50,9 @@ public final class ASTSwitchLabel extends AbstractJavaNode implements Iterable getExprList() { return children(ASTExpression.class); @@ -66,4 +67,12 @@ public final class ASTSwitchLabel extends AbstractJavaNode implements Iterable iterator() { return children(ASTExpression.class).iterator(); } + + /** + * Checks whether this label tests a {@link ASTTypePattern} or a {@link ASTRecordPattern}. + * @since 7.7.0 + */ + public boolean isPatternLabel() { + return children(ASTPattern.class).nonEmpty(); + } } diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/SwitchDensityRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/SwitchDensityRule.java index 1360d29458..a8a6fe6fbe 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/SwitchDensityRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/SwitchDensityRule.java @@ -55,7 +55,7 @@ public class SwitchDensityRule extends AbstractJavaRulechainRule { int stmtCount = node.descendants(ASTStatement.class).count(); int labelCount = node.getBranches() .map(ASTSwitchBranch::getLabel) - .sumBy(label -> label.isDefault() ? 1 : label.getExprList().count()); + .sumBy(label -> label.isDefault() || label.isPatternLabel() ? 1 : label.getExprList().count()); // note: if labelCount is zero, double division will produce +Infinity or NaN, not ArithmeticException double density = stmtCount / (double) labelCount; diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/design/xml/SwitchDensity.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/design/xml/SwitchDensity.xml index 8af61b0af7..4216e0073c 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/design/xml/SwitchDensity.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/design/xml/SwitchDensity.xml @@ -152,6 +152,32 @@ public class SwitchWithDefault { } } +} + ]]> + + + + [java] SwitchDensity false positive with pattern matching #5030 + 4 + 0 + 0 -> + { + System.err.println("I am a fish."); + } + case Integer i -> + { + System.err.println("I am not a fish."); + } + default -> + { + System.err.println("default"); + } + } + } } ]]> From 375fb72f3c99e19f7cab257b02a06f2e29dbf384 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 4 Oct 2024 17:32:46 +0200 Subject: [PATCH 07/52] [java] Fix tree dump test New SwitchLabel#PatternLabel flag --- .../pmd/lang/java/ast/ParserCornerCases17.txt | 34 +++++----- .../pmd/lang/java/ast/SwitchStatements.txt | 8 +-- .../lang/java/ast/SwitchWithFallthrough.txt | 4 +- .../java14/MultipleCaseLabels.txt | 8 +-- .../java14/SimpleSwitchExpressions.txt | 10 +-- .../java14/SwitchExpressions.txt | 42 ++++++------ .../jdkversiontests/java14/SwitchRules.txt | 10 +-- .../java14/YieldStatements.txt | 4 +- .../java21/DealingWithNull.txt | 42 ++++++------ .../java21/EnhancedTypeCheckingSwitch.txt | 12 ++-- .../java21/ExhaustiveSwitch.txt | 26 ++++---- .../java21/GuardedPatterns.txt | 18 +++--- .../java21/Jep440_RecordPatterns.txt | 2 +- .../Jep441_PatternMatchingForSwitch.txt | 64 +++++++++---------- .../java21/PatternsInSwitchLabels.txt | 10 +-- .../java21/RecordPatternsExhaustiveSwitch.txt | 16 ++--- .../java21/RefiningPatternsInSwitch.txt | 20 +++--- .../ScopeOfPatternVariableDeclarations.txt | 14 ++-- .../Jep456_UnnamedPatternsAndVariables.txt | 16 ++--- .../java22p/Jep447_StatementsBeforeSuper.txt | 6 +- ...tiveTypesInPatternsInstanceofAndSwitch.txt | 12 ++-- .../Jep482_FlexibleConstructorBodies.txt | 6 +- 22 files changed, 192 insertions(+), 192 deletions(-) diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/ParserCornerCases17.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/ParserCornerCases17.txt index 553f930c10..bea2307a18 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/ParserCornerCases17.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/ParserCornerCases17.txt @@ -107,39 +107,39 @@ | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "instruction", @Name = "instruction", @ParenthesisDepth = 0, @Parenthesized = false] | | +- NumericLiteral[@Base = 2, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0b11110000", @IntLiteral = true, @Integral = true, @LiteralText = "0b11110000", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 240.0, @ValueAsFloat = 240.0, @ValueAsInt = 240, @ValueAsLong = 240] | +- SwitchFallthroughBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- NumericLiteral[@Base = 2, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0b00000000", @IntLiteral = true, @Integral = true, @LiteralText = "0b00000000", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] | | +- BreakStatement[@Label = null] | +- SwitchFallthroughBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- NumericLiteral[@Base = 2, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0b00010000", @IntLiteral = true, @Integral = true, @LiteralText = "0b00010000", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 16.0, @ValueAsFloat = 16.0, @ValueAsInt = 16, @ValueAsLong = 16] | | +- BreakStatement[@Label = null] | +- SwitchFallthroughBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- NumericLiteral[@Base = 2, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0b00100000", @IntLiteral = true, @Integral = true, @LiteralText = "0b00100000", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 32.0, @ValueAsFloat = 32.0, @ValueAsInt = 32, @ValueAsLong = 32] | | +- BreakStatement[@Label = null] | +- SwitchFallthroughBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- NumericLiteral[@Base = 2, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0b00110000", @IntLiteral = true, @Integral = true, @LiteralText = "0b00110000", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 48.0, @ValueAsFloat = 48.0, @ValueAsInt = 48, @ValueAsLong = 48] | | +- BreakStatement[@Label = null] | +- SwitchFallthroughBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- NumericLiteral[@Base = 2, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0b01000000", @IntLiteral = true, @Integral = true, @LiteralText = "0b01000000", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 64.0, @ValueAsFloat = 64.0, @ValueAsInt = 64, @ValueAsLong = 64] | | +- BreakStatement[@Label = null] | +- SwitchFallthroughBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- NumericLiteral[@Base = 2, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0b01010000", @IntLiteral = true, @Integral = true, @LiteralText = "0b01010000", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 80.0, @ValueAsFloat = 80.0, @ValueAsInt = 80, @ValueAsLong = 80] | | +- BreakStatement[@Label = null] | +- SwitchFallthroughBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- NumericLiteral[@Base = 2, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0b01100000", @IntLiteral = true, @Integral = true, @LiteralText = "0b01100000", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 96.0, @ValueAsFloat = 96.0, @ValueAsInt = 96, @ValueAsLong = 96] | | +- BreakStatement[@Label = null] | +- SwitchFallthroughBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- NumericLiteral[@Base = 2, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0b01110000", @IntLiteral = true, @Integral = true, @LiteralText = "0b01110000", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 112.0, @ValueAsFloat = 112.0, @ValueAsInt = 112, @ValueAsLong = 112] | | +- BreakStatement[@Label = null] | +- SwitchFallthroughBranch[@Default = true] - | +- SwitchLabel[@Default = true] + | +- SwitchLabel[@Default = true, @PatternLabel = false] | +- ThrowStatement[] | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "IllegalArgumentException"] @@ -258,7 +258,7 @@ | +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = true] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "dayOfWeekArg", @Name = "dayOfWeekArg", @ParenthesisDepth = 0, @Parenthesized = false] | | +- SwitchFallthroughBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Monday", @Empty = false, @Image = "\"Monday\"", @Length = 6, @LiteralText = "\"Monday\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | | +- ExpressionStatement[] | | | | +- AssignmentExpression[@CompileTimeConstant = false, @Compound = false, @Operator = AssignmentOp.ASSIGN, @ParenthesisDepth = 0, @Parenthesized = false] @@ -266,13 +266,13 @@ | | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Start of work week", @Empty = false, @Image = "\"Start of work week\"", @Length = 18, @LiteralText = "\"Start of work week\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | | +- BreakStatement[@Label = null] | | +- SwitchFallthroughBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Tuesday", @Empty = false, @Image = "\"Tuesday\"", @Length = 7, @LiteralText = "\"Tuesday\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | +- SwitchFallthroughBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Wednesday", @Empty = false, @Image = "\"Wednesday\"", @Length = 9, @LiteralText = "\"Wednesday\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | +- SwitchFallthroughBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Thursday", @Empty = false, @Image = "\"Thursday\"", @Length = 8, @LiteralText = "\"Thursday\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | | +- ExpressionStatement[] | | | | +- AssignmentExpression[@CompileTimeConstant = false, @Compound = false, @Operator = AssignmentOp.ASSIGN, @ParenthesisDepth = 0, @Parenthesized = false] @@ -280,7 +280,7 @@ | | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Midweek", @Empty = false, @Image = "\"Midweek\"", @Length = 7, @LiteralText = "\"Midweek\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | | +- BreakStatement[@Label = null] | | +- SwitchFallthroughBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Friday", @Empty = false, @Image = "\"Friday\"", @Length = 6, @LiteralText = "\"Friday\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | | +- ExpressionStatement[] | | | | +- AssignmentExpression[@CompileTimeConstant = false, @Compound = false, @Operator = AssignmentOp.ASSIGN, @ParenthesisDepth = 0, @Parenthesized = false] @@ -288,10 +288,10 @@ | | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "End of work week", @Empty = false, @Image = "\"End of work week\"", @Length = 16, @LiteralText = "\"End of work week\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | | +- BreakStatement[@Label = null] | | +- SwitchFallthroughBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Saturday", @Empty = false, @Image = "\"Saturday\"", @Length = 8, @LiteralText = "\"Saturday\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | +- SwitchFallthroughBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Sunday", @Empty = false, @Image = "\"Sunday\"", @Length = 6, @LiteralText = "\"Sunday\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | | +- ExpressionStatement[] | | | | +- AssignmentExpression[@CompileTimeConstant = false, @Compound = false, @Operator = AssignmentOp.ASSIGN, @ParenthesisDepth = 0, @Parenthesized = false] @@ -299,7 +299,7 @@ | | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Weekend", @Empty = false, @Image = "\"Weekend\"", @Length = 7, @LiteralText = "\"Weekend\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | | +- BreakStatement[@Label = null] | | +- SwitchFallthroughBranch[@Default = true] - | | +- SwitchLabel[@Default = true] + | | +- SwitchLabel[@Default = true, @PatternLabel = false] | | +- ThrowStatement[] | | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "IllegalArgumentException"] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/SwitchStatements.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/SwitchStatements.txt index 70874b1031..dbfa7a4509 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/SwitchStatements.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/SwitchStatements.txt @@ -16,16 +16,16 @@ +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = true] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "a", @Name = "a", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchFallthroughBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "1", @IntLiteral = true, @Integral = true, @LiteralText = "1", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 1.0, @ValueAsFloat = 1.0, @ValueAsInt = 1, @ValueAsLong = 1] | +- SwitchFallthroughBranch[@Default = true] - | +- SwitchLabel[@Default = true] + | +- SwitchLabel[@Default = true, @PatternLabel = false] +- SwitchStatement[@DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "a", @Name = "a", @ParenthesisDepth = 0, @Parenthesized = false] +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = true] +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "a", @Name = "a", @ParenthesisDepth = 0, @Parenthesized = false] +- SwitchFallthroughBranch[@Default = false] - | +- SwitchLabel[@Default = false] + | +- SwitchLabel[@Default = false, @PatternLabel = false] | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "1", @IntLiteral = true, @Integral = true, @LiteralText = "1", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 1.0, @ValueAsFloat = 1.0, @ValueAsInt = 1, @ValueAsLong = 1] | +- ExpressionStatement[] | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] @@ -36,4 +36,4 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "1", @Empty = false, @Image = "\"1\"", @Length = 1, @LiteralText = "\"1\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- BreakStatement[@Label = null] +- SwitchFallthroughBranch[@Default = true] - +- SwitchLabel[@Default = true] + +- SwitchLabel[@Default = true, @PatternLabel = false] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/SwitchWithFallthrough.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/SwitchWithFallthrough.txt index 49574ca1a0..5f16e3c6a7 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/SwitchWithFallthrough.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/SwitchWithFallthrough.txt @@ -16,7 +16,7 @@ +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = true] +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "a", @Name = "a", @ParenthesisDepth = 0, @Parenthesized = false] +- SwitchFallthroughBranch[@Default = false] - | +- SwitchLabel[@Default = false] + | +- SwitchLabel[@Default = false, @PatternLabel = false] | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "1", @IntLiteral = true, @Integral = true, @LiteralText = "1", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 1.0, @ValueAsFloat = 1.0, @ValueAsInt = 1, @ValueAsLong = 1] +- SwitchFallthroughBranch[@Default = true] - +- SwitchLabel[@Default = true] + +- SwitchLabel[@Default = true, @PatternLabel = false] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java14/MultipleCaseLabels.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java14/MultipleCaseLabels.txt index 5600a4c3d8..a9007b4787 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java14/MultipleCaseLabels.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java14/MultipleCaseLabels.txt @@ -65,7 +65,7 @@ +- SwitchStatement[@DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = true] +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "day", @Name = "day", @ParenthesisDepth = 0, @Parenthesized = false] +- SwitchFallthroughBranch[@Default = false] - | +- SwitchLabel[@Default = false] + | +- SwitchLabel[@Default = false, @PatternLabel = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = true, @Image = "MONDAY", @Name = "MONDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = true, @Image = "FRIDAY", @Name = "FRIDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = true, @Image = "SUNDAY", @Name = "SUNDAY", @ParenthesisDepth = 0, @Parenthesized = false] @@ -78,7 +78,7 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = " 6", @Empty = false, @Image = "\" 6\"", @Length = 3, @LiteralText = "\" 6\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- BreakStatement[@Label = null] +- SwitchFallthroughBranch[@Default = false] - | +- SwitchLabel[@Default = false] + | +- SwitchLabel[@Default = false, @PatternLabel = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = true, @Image = "TUESDAY", @Name = "TUESDAY", @ParenthesisDepth = 0, @Parenthesized = false] | +- ExpressionStatement[] | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] @@ -89,7 +89,7 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = " 7", @Empty = false, @Image = "\" 7\"", @Length = 3, @LiteralText = "\" 7\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- BreakStatement[@Label = null] +- SwitchFallthroughBranch[@Default = false] - | +- SwitchLabel[@Default = false] + | +- SwitchLabel[@Default = false, @PatternLabel = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = true, @Image = "THURSDAY", @Name = "THURSDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = true, @Image = "SATURDAY", @Name = "SATURDAY", @ParenthesisDepth = 0, @Parenthesized = false] | +- ExpressionStatement[] @@ -101,7 +101,7 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = " 8", @Empty = false, @Image = "\" 8\"", @Length = 3, @LiteralText = "\" 8\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- BreakStatement[@Label = null] +- SwitchFallthroughBranch[@Default = false] - +- SwitchLabel[@Default = false] + +- SwitchLabel[@Default = false, @PatternLabel = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = true, @Image = "WEDNESDAY", @Name = "WEDNESDAY", @ParenthesisDepth = 0, @Parenthesized = false] +- ExpressionStatement[] | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java14/SimpleSwitchExpressions.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java14/SimpleSwitchExpressions.txt index 7eb7d249f3..63cbacf6b4 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java14/SimpleSwitchExpressions.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java14/SimpleSwitchExpressions.txt @@ -69,26 +69,26 @@ | | +- SwitchExpression[@CompileTimeConstant = false, @DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "day", @Name = "day", @ParenthesisDepth = 0, @Parenthesized = false] | | +- SwitchArrowBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = true, @Image = "MONDAY", @Name = "MONDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = true, @Image = "FRIDAY", @Name = "FRIDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = true, @Image = "SUNDAY", @Name = "SUNDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "6", @IntLiteral = true, @Integral = true, @LiteralText = "6", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 6.0, @ValueAsFloat = 6.0, @ValueAsInt = 6, @ValueAsLong = 6] | | +- SwitchArrowBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = true, @Image = "TUESDAY", @Name = "TUESDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "7", @IntLiteral = true, @Integral = true, @LiteralText = "7", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 7.0, @ValueAsFloat = 7.0, @ValueAsInt = 7, @ValueAsLong = 7] | | +- SwitchArrowBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = true, @Image = "THURSDAY", @Name = "THURSDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = true, @Image = "SATURDAY", @Name = "SATURDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "8", @IntLiteral = true, @Integral = true, @LiteralText = "8", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 8.0, @ValueAsFloat = 8.0, @ValueAsInt = 8, @ValueAsLong = 8] | | +- SwitchArrowBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = true, @Image = "WEDNESDAY", @Name = "WEDNESDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "9", @IntLiteral = true, @Integral = true, @LiteralText = "9", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 9.0, @ValueAsFloat = 9.0, @ValueAsInt = 9, @ValueAsLong = 9] | | +- SwitchArrowBranch[@Default = true] - | | +- SwitchLabel[@Default = true] + | | +- SwitchLabel[@Default = true, @PatternLabel = false] | | +- Block[@Empty = false, @Size = 3, @containsComment = false] | | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java14/SwitchExpressions.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java14/SwitchExpressions.txt index 029dca3fd9..72c512b849 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java14/SwitchExpressions.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java14/SwitchExpressions.txt @@ -55,7 +55,7 @@ | +- SwitchStatement[@DefaultCase = false, @EnumSwitch = true, @ExhaustiveEnumSwitch = true, @FallthroughSwitch = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "day", @Name = "day", @ParenthesisDepth = 0, @Parenthesized = false] | | +- SwitchArrowBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "MONDAY", @Name = "MONDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "FRIDAY", @Name = "FRIDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "SUNDAY", @Name = "SUNDAY", @ParenthesisDepth = 0, @Parenthesized = false] @@ -66,7 +66,7 @@ | | | +- ArgumentList[@Empty = false, @Size = 1] | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "6", @IntLiteral = true, @Integral = true, @LiteralText = "6", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 6.0, @ValueAsFloat = 6.0, @ValueAsInt = 6, @ValueAsLong = 6] | | +- SwitchArrowBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "TUESDAY", @Name = "TUESDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] @@ -75,7 +75,7 @@ | | | +- ArgumentList[@Empty = false, @Size = 1] | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "7", @IntLiteral = true, @Integral = true, @LiteralText = "7", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 7.0, @ValueAsFloat = 7.0, @ValueAsInt = 7, @ValueAsLong = 7] | | +- SwitchArrowBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "THURSDAY", @Name = "THURSDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "SATURDAY", @Name = "SATURDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] @@ -85,7 +85,7 @@ | | | +- ArgumentList[@Empty = false, @Size = 1] | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "8", @IntLiteral = true, @Integral = true, @LiteralText = "8", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 8.0, @ValueAsFloat = 8.0, @ValueAsInt = 8, @ValueAsLong = 8] | | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "WEDNESDAY", @Name = "WEDNESDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] @@ -101,22 +101,22 @@ | | +- SwitchExpression[@CompileTimeConstant = false, @DefaultCase = false, @EnumSwitch = true, @ExhaustiveEnumSwitch = true, @FallthroughSwitch = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "day", @Name = "day", @ParenthesisDepth = 0, @Parenthesized = false] | | +- SwitchArrowBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "MONDAY", @Name = "MONDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "FRIDAY", @Name = "FRIDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "SUNDAY", @Name = "SUNDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "6", @IntLiteral = true, @Integral = true, @LiteralText = "6", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 6.0, @ValueAsFloat = 6.0, @ValueAsInt = 6, @ValueAsLong = 6] | | +- SwitchArrowBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "TUESDAY", @Name = "TUESDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "7", @IntLiteral = true, @Integral = true, @LiteralText = "7", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 7.0, @ValueAsFloat = 7.0, @ValueAsInt = 7, @ValueAsLong = 7] | | +- SwitchArrowBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "THURSDAY", @Name = "THURSDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "SATURDAY", @Name = "SATURDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "8", @IntLiteral = true, @Integral = true, @LiteralText = "8", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 8.0, @ValueAsFloat = 8.0, @ValueAsInt = 8, @ValueAsLong = 8] | | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "WEDNESDAY", @Name = "WEDNESDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "9", @IntLiteral = true, @Integral = true, @LiteralText = "9", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 9.0, @ValueAsFloat = 9.0, @ValueAsInt = 9, @ValueAsLong = 9] | +- ExpressionStatement[] @@ -159,15 +159,15 @@ | | +- SwitchExpression[@CompileTimeConstant = false, @DefaultCase = true, @EnumSwitch = true, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "day", @Name = "day", @ParenthesisDepth = 0, @Parenthesized = false] | | +- SwitchArrowBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "MONDAY", @Name = "MONDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] | | +- SwitchArrowBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "TUESDAY", @Name = "TUESDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "1", @IntLiteral = true, @Integral = true, @LiteralText = "1", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 1.0, @ValueAsFloat = 1.0, @ValueAsInt = 1, @ValueAsLong = 1] | | +- SwitchArrowBranch[@Default = true] - | | +- SwitchLabel[@Default = true] + | | +- SwitchLabel[@Default = true, @PatternLabel = false] | | +- Block[@Empty = false, @Size = 3, @containsComment = false] | | +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] @@ -211,24 +211,24 @@ | | +- SwitchExpression[@CompileTimeConstant = false, @DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = true, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] | | +- SwitchFallthroughBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Foo", @Empty = false, @Image = "\"Foo\"", @Length = 3, @LiteralText = "\"Foo\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | | +- YieldStatement[] | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "1", @IntLiteral = true, @Integral = true, @LiteralText = "1", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 1.0, @ValueAsFloat = 1.0, @ValueAsInt = 1, @ValueAsLong = 1] | | +- SwitchFallthroughBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Bar", @Empty = false, @Image = "\"Bar\"", @Length = 3, @LiteralText = "\"Bar\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | | +- YieldStatement[] | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "2", @IntLiteral = true, @Integral = true, @LiteralText = "2", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 2.0, @ValueAsFloat = 2.0, @ValueAsInt = 2, @ValueAsLong = 2] | | +- SwitchFallthroughBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Baz", @Empty = false, @Image = "\"Baz\"", @Length = 3, @LiteralText = "\"Baz\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | | +- YieldStatement[] | | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = true, @Image = "BAZ", @Name = "BAZ", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "SwitchExpressions"] | | +- SwitchFallthroughBranch[@Default = true] - | | +- SwitchLabel[@Default = true] + | | +- SwitchLabel[@Default = true, @PatternLabel = false] | | +- ExpressionStatement[] | | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] @@ -258,7 +258,7 @@ | +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "k", @Name = "k", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "1", @IntLiteral = true, @Integral = true, @LiteralText = "1", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 1.0, @ValueAsFloat = 1.0, @ValueAsInt = 1, @ValueAsLong = 1] | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] @@ -267,7 +267,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "one", @Empty = false, @Image = "\"one\"", @Length = 3, @LiteralText = "\"one\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "2", @IntLiteral = true, @Integral = true, @LiteralText = "2", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 2.0, @ValueAsFloat = 2.0, @ValueAsInt = 2, @ValueAsLong = 2] | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] @@ -276,7 +276,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "two", @Empty = false, @Image = "\"two\"", @Length = 3, @LiteralText = "\"two\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = true] - | +- SwitchLabel[@Default = true] + | +- SwitchLabel[@Default = true, @PatternLabel = false] | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] @@ -301,15 +301,15 @@ | +- SwitchExpression[@CompileTimeConstant = false, @DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false, @ParenthesisDepth = 0, @Parenthesized = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "k", @Name = "k", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "1", @IntLiteral = true, @Integral = true, @LiteralText = "1", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 1.0, @ValueAsFloat = 1.0, @ValueAsInt = 1, @ValueAsLong = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "one", @Empty = false, @Image = "\"one\"", @Length = 3, @LiteralText = "\"one\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "2", @IntLiteral = true, @Integral = true, @LiteralText = "2", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 2.0, @ValueAsFloat = 2.0, @ValueAsInt = 2, @ValueAsLong = 2] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "two", @Empty = false, @Image = "\"two\"", @Length = 3, @LiteralText = "\"two\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = true] - | +- SwitchLabel[@Default = true] + | +- SwitchLabel[@Default = true, @PatternLabel = false] | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "many", @Empty = false, @Image = "\"many\"", @Length = 4, @LiteralText = "\"many\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PRIVATE, @Final = false, @Name = "f", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PRIVATE, @Void = false] +- ModifierList[@EffectiveModifiers = (JModifier.PRIVATE, JModifier.STATIC), @ExplicitModifiers = (JModifier.PRIVATE, JModifier.STATIC)] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java14/SwitchRules.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java14/SwitchRules.txt index 812fecf840..4eb465db71 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java14/SwitchRules.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java14/SwitchRules.txt @@ -65,7 +65,7 @@ +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "day", @Name = "day", @ParenthesisDepth = 0, @Parenthesized = false] +- SwitchArrowBranch[@Default = false] - | +- SwitchLabel[@Default = false] + | +- SwitchLabel[@Default = false, @PatternLabel = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = true, @Image = "MONDAY", @Name = "MONDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = true, @Image = "FRIDAY", @Name = "FRIDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = true, @Image = "SUNDAY", @Name = "SUNDAY", @ParenthesisDepth = 0, @Parenthesized = false] @@ -76,7 +76,7 @@ | +- ArgumentList[@Empty = false, @Size = 1] | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = " 6", @Empty = false, @Image = "\" 6\"", @Length = 3, @LiteralText = "\" 6\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] +- SwitchArrowBranch[@Default = false] - | +- SwitchLabel[@Default = false] + | +- SwitchLabel[@Default = false, @PatternLabel = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = true, @Image = "TUESDAY", @Name = "TUESDAY", @ParenthesisDepth = 0, @Parenthesized = false] | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] @@ -85,7 +85,7 @@ | +- ArgumentList[@Empty = false, @Size = 1] | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = " 7", @Empty = false, @Image = "\" 7\"", @Length = 3, @LiteralText = "\" 7\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] +- SwitchArrowBranch[@Default = false] - | +- SwitchLabel[@Default = false] + | +- SwitchLabel[@Default = false, @PatternLabel = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = true, @Image = "THURSDAY", @Name = "THURSDAY", @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = true, @Image = "SATURDAY", @Name = "SATURDAY", @ParenthesisDepth = 0, @Parenthesized = false] | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] @@ -95,7 +95,7 @@ | +- ArgumentList[@Empty = false, @Size = 1] | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = " 8", @Empty = false, @Image = "\" 8\"", @Length = 3, @LiteralText = "\" 8\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] +- SwitchArrowBranch[@Default = false] - | +- SwitchLabel[@Default = false] + | +- SwitchLabel[@Default = false, @PatternLabel = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = true, @Image = "WEDNESDAY", @Name = "WEDNESDAY", @ParenthesisDepth = 0, @Parenthesized = false] | +- Block[@Empty = false, @Size = 1, @containsComment = false] | +- ExpressionStatement[] @@ -106,7 +106,7 @@ | +- ArgumentList[@Empty = false, @Size = 1] | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = " 9", @Empty = false, @Image = "\" 9\"", @Length = 3, @LiteralText = "\" 9\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] +- SwitchArrowBranch[@Default = true] - +- SwitchLabel[@Default = true] + +- SwitchLabel[@Default = true, @PatternLabel = false] +- ThrowStatement[] +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "IllegalArgumentException"] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java14/YieldStatements.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java14/YieldStatements.txt index bbab68e109..766c74cde2 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java14/YieldStatements.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java14/YieldStatements.txt @@ -29,7 +29,7 @@ +- SwitchExpression[@CompileTimeConstant = false, @DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false, @ParenthesisDepth = 0, @Parenthesized = false] +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "e", @Name = "e", @ParenthesisDepth = 0, @Parenthesized = false] +- SwitchArrowBranch[@Default = false] - +- SwitchLabel[@Default = false] + +- SwitchLabel[@Default = false, @PatternLabel = false] | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "1", @IntLiteral = true, @Integral = true, @LiteralText = "1", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 1.0, @ValueAsFloat = 1.0, @ValueAsInt = 1, @ValueAsLong = 1] +- Block[@Empty = false, @Size = 12, @containsComment = true] +- ExpressionStatement[] @@ -67,7 +67,7 @@ | +- SwitchExpression[@CompileTimeConstant = false, @DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false, @ParenthesisDepth = 0, @Parenthesized = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "foo", @Name = "foo", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | +- SwitchLabel[@Default = false] + | +- SwitchLabel[@Default = false, @PatternLabel = false] | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "4", @IntLiteral = true, @Integral = true, @LiteralText = "4", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 4.0, @ValueAsFloat = 4.0, @ValueAsInt = 4, @ValueAsLong = 4] | +- Block[@Empty = false, @Size = 1, @containsComment = false] | +- YieldStatement[] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/DealingWithNull.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/DealingWithNull.txt index fe8144121b..1eb5bde018 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/DealingWithNull.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/DealingWithNull.txt @@ -14,7 +14,7 @@ | +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false] | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] @@ -23,7 +23,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Oops", @Empty = false, @Image = "\"Oops\"", @Length = 4, @LiteralText = "\"Oops\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Foo", @Empty = false, @Image = "\"Foo\"", @Length = 3, @LiteralText = "\"Foo\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Bar", @Empty = false, @Image = "\"Bar\"", @Length = 3, @LiteralText = "\"Bar\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] @@ -33,7 +33,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Great", @Empty = false, @Image = "\"Great\"", @Length = 5, @LiteralText = "\"Great\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = true] - | +- SwitchLabel[@Default = true] + | +- SwitchLabel[@Default = true, @PatternLabel = false] | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] @@ -52,7 +52,7 @@ | +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "String"] @@ -66,7 +66,7 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "String: ", @Empty = false, @Image = "\"String: \"", @Length = 8, @LiteralText = "\"String: \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false] | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] @@ -75,7 +75,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "null", @Empty = false, @Image = "\"null\"", @Length = 4, @LiteralText = "\"null\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = true] - | +- SwitchLabel[@Default = true] + | +- SwitchLabel[@Default = true, @PatternLabel = false] | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] @@ -94,7 +94,7 @@ | +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "String"] @@ -108,7 +108,7 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "String: ", @Empty = false, @Image = "\"String: \"", @Length = 8, @LiteralText = "\"String: \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = true] - | +- SwitchLabel[@Default = true] + | +- SwitchLabel[@Default = true, @PatternLabel = false] | | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false] | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] @@ -128,14 +128,14 @@ | +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ThrowStatement[] | | +- ConstructorCall[@AnonymousClass = false, @CompileTimeConstant = false, @DiamondTypeArgs = false, @MethodName = "new", @ParenthesisDepth = 0, @Parenthesized = false, @QualifiedInstanceCreation = false] | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "NullPointerException"] | | +- ArgumentList[@Empty = true, @Size = 0] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "String"] @@ -149,7 +149,7 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "String: ", @Empty = false, @Image = "\"String: \"", @Length = 8, @LiteralText = "\"String: \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Integer"] @@ -161,7 +161,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Integer", @Empty = false, @Image = "\"Integer\"", @Length = 7, @LiteralText = "\"Integer\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = true] - | +- SwitchLabel[@Default = true] + | +- SwitchLabel[@Default = true, @PatternLabel = false] | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] @@ -180,7 +180,7 @@ | +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = true] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] | | +- SwitchFallthroughBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- ExpressionStatement[] | | | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] @@ -191,7 +191,7 @@ | | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "null", @Empty = false, @Image = "\"null\"", @Length = 4, @LiteralText = "\"null\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | | +- BreakStatement[@Label = null] | | +- SwitchFallthroughBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "String"] @@ -205,7 +205,7 @@ | | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "String", @Empty = false, @Image = "\"String\"", @Length = 6, @LiteralText = "\"String\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | | +- BreakStatement[@Label = null] | | +- SwitchFallthroughBranch[@Default = true] - | | +- SwitchLabel[@Default = true] + | | +- SwitchLabel[@Default = true, @PatternLabel = false] | | +- ExpressionStatement[] | | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] @@ -217,7 +217,7 @@ | +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] | | +- SwitchArrowBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] @@ -226,7 +226,7 @@ | | | +- ArgumentList[@Empty = false, @Size = 1] | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "null", @Empty = false, @Image = "\"null\"", @Length = 4, @LiteralText = "\"null\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | +- SwitchArrowBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "String"] @@ -238,7 +238,7 @@ | | | +- ArgumentList[@Empty = false, @Size = 1] | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "String", @Empty = false, @Image = "\"String\"", @Length = 6, @LiteralText = "\"String\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | +- SwitchArrowBranch[@Default = true] - | | +- SwitchLabel[@Default = true] + | | +- SwitchLabel[@Default = true, @PatternLabel = false] | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] @@ -248,10 +248,10 @@ | +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = true] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] | | +- SwitchFallthroughBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false] | | +- SwitchFallthroughBranch[@Default = true] - | | +- SwitchLabel[@Default = true] + | | +- SwitchLabel[@Default = true, @PatternLabel = false] | | +- ExpressionStatement[] | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] @@ -262,7 +262,7 @@ | +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = true] - | +- SwitchLabel[@Default = true] + | +- SwitchLabel[@Default = true, @PatternLabel = false] | | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false] | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/EnhancedTypeCheckingSwitch.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/EnhancedTypeCheckingSwitch.txt index 71d642290e..aec1b52224 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/EnhancedTypeCheckingSwitch.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/EnhancedTypeCheckingSwitch.txt @@ -38,7 +38,7 @@ | +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "obj", @Name = "obj", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false] | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] @@ -47,7 +47,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "null", @Empty = false, @Image = "\"null\"", @Length = 4, @LiteralText = "\"null\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "String"] @@ -59,7 +59,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "String", @Empty = false, @Image = "\"String\"", @Length = 6, @LiteralText = "\"String\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Color"] @@ -75,7 +75,7 @@ | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "c", @Name = "c", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArgumentList[@Empty = true, @Size = 0] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Point"] @@ -91,7 +91,7 @@ | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "p", @Name = "p", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArgumentList[@Empty = true, @Size = 0] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ArrayType[@ArrayDepth = 1] @@ -109,7 +109,7 @@ | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "length", @Name = "length", @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "ia", @Name = "ia", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = true] - | +- SwitchLabel[@Default = true] + | +- SwitchLabel[@Default = true, @PatternLabel = false] | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/ExhaustiveSwitch.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/ExhaustiveSwitch.txt index b43f4f1caf..0690ebc5ba 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/ExhaustiveSwitch.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/ExhaustiveSwitch.txt @@ -15,7 +15,7 @@ | +- SwitchExpression[@CompileTimeConstant = false, @DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false, @ParenthesisDepth = 0, @Parenthesized = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "obj", @Name = "obj", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "String"] @@ -24,14 +24,14 @@ | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArgumentList[@Empty = true, @Size = 0] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Integer"] | | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "i", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @Static = false, @TypeInferred = false, @Unnamed = false, @Visibility = Visibility.V_LOCAL] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "i", @Name = "i", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = true] - | +- SwitchLabel[@Default = true] + | +- SwitchLabel[@Default = true, @PatternLabel = false] | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "0", @IntLiteral = true, @Integral = true, @LiteralText = "0", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Name = "coverageStatement", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] | +- ModifierList[@EffectiveModifiers = (JModifier.STATIC), @ExplicitModifiers = (JModifier.STATIC)] @@ -45,7 +45,7 @@ | +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = true] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchFallthroughBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "String"] @@ -59,7 +59,7 @@ | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] | | +- BreakStatement[@Label = null] | +- SwitchFallthroughBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Integer"] @@ -73,7 +73,7 @@ | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Integer", @Empty = false, @Image = "\"Integer\"", @Length = 7, @LiteralText = "\"Integer\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | +- BreakStatement[@Label = null] | +- SwitchFallthroughBranch[@Default = true] - | +- SwitchLabel[@Default = true] + | +- SwitchLabel[@Default = true, @PatternLabel = false] | +- BreakStatement[@Label = null] +- ClassDeclaration[@Abstract = true, @Annotation = false, @Anonymous = false, @BinaryName = "ExhaustiveSwitch$S", @CanonicalName = "ExhaustiveSwitch.S", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = false, @Interface = true, @Local = false, @Nested = true, @PackageName = "", @Record = false, @RegularClass = false, @RegularInterface = true, @SimpleName = "S", @Static = true, @TopLevel = false, @UnnamedToplevelClass = false, @Visibility = Visibility.V_PACKAGE] | +- ModifierList[@EffectiveModifiers = (JModifier.SEALED, JModifier.ABSTRACT, JModifier.STATIC), @ExplicitModifiers = (JModifier.SEALED)] @@ -115,21 +115,21 @@ | +- SwitchExpression[@CompileTimeConstant = false, @DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false, @ParenthesisDepth = 0, @Parenthesized = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "A"] | | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "a", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @Static = false, @TypeInferred = false, @Unnamed = false, @Visibility = Visibility.V_LOCAL] | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "1", @IntLiteral = true, @Integral = true, @LiteralText = "1", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 1.0, @ValueAsFloat = 1.0, @ValueAsInt = 1, @ValueAsLong = 1] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "B"] | | | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "b", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @Static = false, @TypeInferred = false, @Unnamed = false, @Visibility = Visibility.V_LOCAL] | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = false, @Image = "2", @IntLiteral = true, @Integral = true, @LiteralText = "2", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 2.0, @ValueAsFloat = 2.0, @ValueAsInt = 2, @ValueAsLong = 2] | +- SwitchArrowBranch[@Default = false] - | +- SwitchLabel[@Default = false] + | +- SwitchLabel[@Default = false, @PatternLabel = true] | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "C"] @@ -147,7 +147,7 @@ | +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = true] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] | | +- SwitchFallthroughBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "A"] @@ -161,7 +161,7 @@ | | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "A", @Empty = false, @Image = "\"A\"", @Length = 1, @LiteralText = "\"A\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | | +- BreakStatement[@Label = null] | | +- SwitchFallthroughBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "C"] @@ -175,7 +175,7 @@ | | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "C", @Empty = false, @Image = "\"C\"", @Length = 1, @LiteralText = "\"C\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | | +- BreakStatement[@Label = null] | | +- SwitchFallthroughBranch[@Default = true] - | | +- SwitchLabel[@Default = true] + | | +- SwitchLabel[@Default = true, @PatternLabel = false] | | +- ExpressionStatement[] | | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] @@ -226,7 +226,7 @@ | +- SwitchExpression[@CompileTimeConstant = false, @DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false, @ParenthesisDepth = 0, @Parenthesized = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "i", @Name = "i", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | +- SwitchLabel[@Default = false] + | +- SwitchLabel[@Default = false, @PatternLabel = true] | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "F"] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/GuardedPatterns.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/GuardedPatterns.txt index 6e33db0bd7..e9ec43cda3 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/GuardedPatterns.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/GuardedPatterns.txt @@ -14,7 +14,7 @@ | +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "String"] @@ -32,7 +32,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "single char string", @Empty = false, @Image = "\"single char string\"", @Length = 18, @LiteralText = "\"single char string\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "String"] @@ -44,7 +44,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "string", @Empty = false, @Image = "\"string\"", @Length = 6, @LiteralText = "\"string\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Integer"] @@ -62,7 +62,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "integer 1", @Empty = false, @Image = "\"integer 1\"", @Length = 9, @LiteralText = "\"integer 1\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = true] - | +- SwitchLabel[@Default = true] + | +- SwitchLabel[@Default = true, @PatternLabel = false] | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] @@ -118,7 +118,7 @@ | +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "String"] @@ -136,7 +136,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "single char string", @Empty = false, @Image = "\"single char string\"", @Length = 18, @LiteralText = "\"single char string\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "String"] @@ -148,7 +148,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "string", @Empty = false, @Image = "\"string\"", @Length = 6, @LiteralText = "\"string\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Integer"] @@ -166,7 +166,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "integer 1", @Empty = false, @Image = "\"integer 1\"", @Length = 9, @LiteralText = "\"integer 1\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false] | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] @@ -175,7 +175,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "null!", @Empty = false, @Image = "\"null!\"", @Length = 5, @LiteralText = "\"null!\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = true] - | +- SwitchLabel[@Default = true] + | +- SwitchLabel[@Default = true, @PatternLabel = false] | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/Jep440_RecordPatterns.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/Jep440_RecordPatterns.txt index 84f45093b7..8756417a53 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/Jep440_RecordPatterns.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/Jep440_RecordPatterns.txt @@ -260,7 +260,7 @@ | +- SwitchStatement[@DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "pair", @Name = "pair", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | +- SwitchLabel[@Default = false] + | +- SwitchLabel[@Default = false, @PatternLabel = true] | | +- RecordPattern[] | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "MyPair"] | | +- PatternList[@Empty = false, @Size = 2] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/Jep441_PatternMatchingForSwitch.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/Jep441_PatternMatchingForSwitch.txt index 97893e90d3..fce6b81fdf 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/Jep441_PatternMatchingForSwitch.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/Jep441_PatternMatchingForSwitch.txt @@ -15,7 +15,7 @@ | +- SwitchExpression[@CompileTimeConstant = false, @DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false, @ParenthesisDepth = 0, @Parenthesized = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "obj", @Name = "obj", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Integer"] @@ -27,7 +27,7 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "int %d", @Empty = false, @Image = "\"int %d\"", @Length = 6, @LiteralText = "\"int %d\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "i", @Name = "i", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Long"] @@ -39,7 +39,7 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "long %d", @Empty = false, @Image = "\"long %d\"", @Length = 7, @LiteralText = "\"long %d\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "l", @Name = "l", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Double"] @@ -51,7 +51,7 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "double %f", @Empty = false, @Image = "\"double %f\"", @Length = 9, @LiteralText = "\"double %f\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "d", @Name = "d", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "String"] @@ -63,7 +63,7 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "String %s", @Empty = false, @Image = "\"String %s\"", @Length = 9, @LiteralText = "\"String %s\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = true] - | +- SwitchLabel[@Default = true] + | +- SwitchLabel[@Default = true, @PatternLabel = false] | +- MethodCall[@CompileTimeConstant = false, @Image = "toString", @MethodName = "toString", @ParenthesisDepth = 0, @Parenthesized = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "obj", @Name = "obj", @ParenthesisDepth = 0, @Parenthesized = false] | +- ArgumentList[@Empty = true, @Size = 0] @@ -79,7 +79,7 @@ | +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false] | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] @@ -88,7 +88,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Oops", @Empty = false, @Image = "\"Oops\"", @Length = 4, @LiteralText = "\"Oops\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Foo", @Empty = false, @Image = "\"Foo\"", @Length = 3, @LiteralText = "\"Foo\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Bar", @Empty = false, @Image = "\"Bar\"", @Length = 3, @LiteralText = "\"Bar\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] @@ -98,7 +98,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Great", @Empty = false, @Image = "\"Great\"", @Length = 5, @LiteralText = "\"Great\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = true] - | +- SwitchLabel[@Default = true] + | +- SwitchLabel[@Default = true, @PatternLabel = false] | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] @@ -117,11 +117,11 @@ | +- SwitchStatement[@DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "response", @Name = "response", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false] | | +- Block[@Empty = true, @Size = 0, @containsComment = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "String"] @@ -140,7 +140,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "You got it", @Empty = false, @Image = "\"You got it\"", @Length = 10, @LiteralText = "\"You got it\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "String"] @@ -159,7 +159,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Shame", @Empty = false, @Image = "\"Shame\"", @Length = 5, @LiteralText = "\"Shame\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | +- SwitchLabel[@Default = false] + | +- SwitchLabel[@Default = false, @PatternLabel = true] | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "String"] @@ -184,11 +184,11 @@ | +- SwitchStatement[@DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "response", @Name = "response", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false] | | +- Block[@Empty = true, @Size = 0, @containsComment = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "y", @Empty = false, @Image = "\"y\"", @Length = 1, @LiteralText = "\"y\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Y", @Empty = false, @Image = "\"Y\"", @Length = 1, @LiteralText = "\"Y\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | +- Block[@Empty = false, @Size = 1, @containsComment = false] @@ -200,7 +200,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "You got it", @Empty = false, @Image = "\"You got it\"", @Length = 10, @LiteralText = "\"You got it\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "n", @Empty = false, @Image = "\"n\"", @Length = 1, @LiteralText = "\"n\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "N", @Empty = false, @Image = "\"N\"", @Length = 1, @LiteralText = "\"N\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | +- Block[@Empty = false, @Size = 1, @containsComment = false] @@ -212,7 +212,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Shame", @Empty = false, @Image = "\"Shame\"", @Length = 5, @LiteralText = "\"Shame\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "String"] @@ -231,7 +231,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "You got it", @Empty = false, @Image = "\"You got it\"", @Length = 10, @LiteralText = "\"You got it\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "String"] @@ -250,7 +250,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Shame", @Empty = false, @Image = "\"Shame\"", @Length = 5, @LiteralText = "\"Shame\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | +- SwitchLabel[@Default = false] + | +- SwitchLabel[@Default = false, @PatternLabel = true] | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "String"] @@ -303,7 +303,7 @@ | +- SwitchStatement[@DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "c", @Name = "c", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Suit"] @@ -323,7 +323,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "It\'s clubs", @Empty = false, @Image = "\"It\'s clubs\"", @Length = 10, @LiteralText = "\"It\'s clubs\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Suit"] @@ -343,7 +343,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "It\'s diamonds", @Empty = false, @Image = "\"It\'s diamonds\"", @Length = 13, @LiteralText = "\"It\'s diamonds\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Suit"] @@ -363,7 +363,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "It\'s hearts", @Empty = false, @Image = "\"It\'s hearts\"", @Length = 11, @LiteralText = "\"It\'s hearts\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Suit"] @@ -377,7 +377,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "It\'s spades", @Empty = false, @Image = "\"It\'s spades\"", @Length = 11, @LiteralText = "\"It\'s spades\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | +- SwitchLabel[@Default = false] + | +- SwitchLabel[@Default = false, @PatternLabel = true] | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Tarot"] @@ -402,7 +402,7 @@ | +- SwitchStatement[@DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "c", @Name = "c", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "CLUBS", @Name = "CLUBS", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Suit"] @@ -415,7 +415,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "It\'s clubs", @Empty = false, @Image = "\"It\'s clubs\"", @Length = 10, @LiteralText = "\"It\'s clubs\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "DIAMONDS", @Name = "DIAMONDS", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Suit"] @@ -428,7 +428,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "It\'s diamonds", @Empty = false, @Image = "\"It\'s diamonds\"", @Length = 13, @LiteralText = "\"It\'s diamonds\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "HEARTS", @Name = "HEARTS", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Suit"] @@ -441,7 +441,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "It\'s hearts", @Empty = false, @Image = "\"It\'s hearts\"", @Length = 11, @LiteralText = "\"It\'s hearts\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "SPADES", @Name = "SPADES", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Suit"] @@ -454,7 +454,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "It\'s spades", @Empty = false, @Image = "\"It\'s spades\"", @Length = 11, @LiteralText = "\"It\'s spades\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | +- SwitchLabel[@Default = false] + | +- SwitchLabel[@Default = false, @PatternLabel = true] | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Tarot"] @@ -495,7 +495,7 @@ | +- SwitchStatement[@DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "c", @Name = "c", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "HEADS", @Name = "HEADS", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Coin"] @@ -508,7 +508,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Heads", @Empty = false, @Image = "\"Heads\"", @Length = 5, @LiteralText = "\"Heads\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | +- SwitchLabel[@Default = false] + | +- SwitchLabel[@Default = false, @PatternLabel = false] | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "TAILS", @Name = "TAILS", @ParenthesisDepth = 0, @Parenthesized = false] | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Coin"] @@ -532,7 +532,7 @@ +- SwitchStatement[@DefaultCase = false, @EnumSwitch = true, @ExhaustiveEnumSwitch = true, @FallthroughSwitch = false] +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "c", @Name = "c", @ParenthesisDepth = 0, @Parenthesized = false] +- SwitchArrowBranch[@Default = false] - | +- SwitchLabel[@Default = false] + | +- SwitchLabel[@Default = false, @PatternLabel = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "HEADS", @Name = "HEADS", @ParenthesisDepth = 0, @Parenthesized = false] | +- Block[@Empty = false, @Size = 1, @containsComment = false] | +- ExpressionStatement[] @@ -543,7 +543,7 @@ | +- ArgumentList[@Empty = false, @Size = 1] | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Heads", @Empty = false, @Image = "\"Heads\"", @Length = 5, @LiteralText = "\"Heads\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] +- SwitchArrowBranch[@Default = false] - +- SwitchLabel[@Default = false] + +- SwitchLabel[@Default = false, @PatternLabel = false] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "TAILS", @Name = "TAILS", @ParenthesisDepth = 0, @Parenthesized = false] | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Coin"] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/PatternsInSwitchLabels.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/PatternsInSwitchLabels.txt index c77d9dc179..c78fee3b6c 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/PatternsInSwitchLabels.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/PatternsInSwitchLabels.txt @@ -28,7 +28,7 @@ | +- SwitchExpression[@CompileTimeConstant = false, @DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false, @ParenthesisDepth = 0, @Parenthesized = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Integer"] @@ -40,7 +40,7 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "int %d", @Empty = false, @Image = "\"int %d\"", @Length = 6, @LiteralText = "\"int %d\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "i", @Name = "i", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Long"] @@ -52,7 +52,7 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "long %d", @Empty = false, @Image = "\"long %d\"", @Length = 7, @LiteralText = "\"long %d\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "l", @Name = "l", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Double"] @@ -64,7 +64,7 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "double %f", @Empty = false, @Image = "\"double %f\"", @Length = 9, @LiteralText = "\"double %f\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "d", @Name = "d", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "String"] @@ -76,7 +76,7 @@ | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "String %s", @Empty = false, @Image = "\"String %s\"", @Length = 9, @LiteralText = "\"String %s\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = true] - | +- SwitchLabel[@Default = true] + | +- SwitchLabel[@Default = true, @PatternLabel = false] | +- MethodCall[@CompileTimeConstant = false, @Image = "toString", @MethodName = "toString", @ParenthesisDepth = 0, @Parenthesized = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] | +- ArgumentList[@Empty = true, @Size = 0] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatternsExhaustiveSwitch.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatternsExhaustiveSwitch.txt index ce5ef0f93d..78a8d5d495 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatternsExhaustiveSwitch.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RecordPatternsExhaustiveSwitch.txt @@ -64,7 +64,7 @@ +- SwitchStatement[@DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "p1", @Name = "p1", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- RecordPattern[] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Pair"] | | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] @@ -85,7 +85,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "a", @Empty = false, @Image = "\"a\"", @Length = 1, @LiteralText = "\"a\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- RecordPattern[] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Pair"] | | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] @@ -106,7 +106,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "a", @Empty = false, @Image = "\"a\"", @Length = 1, @LiteralText = "\"a\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | +- SwitchLabel[@Default = false] + | +- SwitchLabel[@Default = false, @PatternLabel = true] | | +- RecordPattern[] | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Pair"] | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] @@ -129,7 +129,7 @@ +- SwitchStatement[@DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "p2", @Name = "p2", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- RecordPattern[] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Pair"] | | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] @@ -150,7 +150,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "a", @Empty = false, @Image = "\"a\"", @Length = 1, @LiteralText = "\"a\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | +- SwitchLabel[@Default = false] + | +- SwitchLabel[@Default = false, @PatternLabel = true] | | +- RecordPattern[] | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Pair"] | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] @@ -173,7 +173,7 @@ +- SwitchStatement[@DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "p2", @Name = "p2", @ParenthesisDepth = 0, @Parenthesized = false] +- SwitchArrowBranch[@Default = false] - | +- SwitchLabel[@Default = false] + | +- SwitchLabel[@Default = false, @PatternLabel = true] | | +- RecordPattern[] | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Pair"] | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] @@ -194,7 +194,7 @@ | +- ArgumentList[@Empty = false, @Size = 1] | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "a", @Empty = false, @Image = "\"a\"", @Length = 1, @LiteralText = "\"a\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] +- SwitchArrowBranch[@Default = false] - | +- SwitchLabel[@Default = false] + | +- SwitchLabel[@Default = false, @PatternLabel = true] | | +- RecordPattern[] | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Pair"] | | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] @@ -215,7 +215,7 @@ | +- ArgumentList[@Empty = false, @Size = 1] | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "a", @Empty = false, @Image = "\"a\"", @Length = 1, @LiteralText = "\"a\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] +- SwitchArrowBranch[@Default = false] - +- SwitchLabel[@Default = false] + +- SwitchLabel[@Default = false, @PatternLabel = true] | +- RecordPattern[] | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Pair"] | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RefiningPatternsInSwitch.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RefiningPatternsInSwitch.txt index 60f0406293..8090943eaf 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RefiningPatternsInSwitch.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/RefiningPatternsInSwitch.txt @@ -52,11 +52,11 @@ | +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = true] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchFallthroughBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false] | | +- BreakStatement[@Label = null] | +- SwitchFallthroughBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Triangle"] @@ -77,7 +77,7 @@ | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Large triangle", @Empty = false, @Image = "\"Large triangle\"", @Length = 14, @LiteralText = "\"Large triangle\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | +- BreakStatement[@Label = null] | +- SwitchFallthroughBranch[@Default = true] - | +- SwitchLabel[@Default = true] + | +- SwitchLabel[@Default = true, @PatternLabel = false] | +- ExpressionStatement[] | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] @@ -97,12 +97,12 @@ | +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false] | | +- Block[@Empty = false, @Size = 1, @containsComment = false] | | +- BreakStatement[@Label = null] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Triangle"] @@ -120,7 +120,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Large triangle", @Empty = false, @Image = "\"Large triangle\"", @Length = 14, @LiteralText = "\"Large triangle\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = true] - | +- SwitchLabel[@Default = true] + | +- SwitchLabel[@Default = true, @PatternLabel = false] | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] @@ -139,12 +139,12 @@ | +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- NullLiteral[@CompileTimeConstant = false, @LiteralText = "null", @ParenthesisDepth = 0, @Parenthesized = false] | | +- Block[@Empty = false, @Size = 1, @containsComment = false] | | +- BreakStatement[@Label = null] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Triangle"] @@ -162,7 +162,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Large triangle", @Empty = false, @Image = "\"Large triangle\"", @Length = 14, @LiteralText = "\"Large triangle\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Triangle"] @@ -174,7 +174,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Small triangle", @Empty = false, @Image = "\"Small triangle\"", @Length = 14, @LiteralText = "\"Small triangle\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = true] - | +- SwitchLabel[@Default = true] + | +- SwitchLabel[@Default = true, @PatternLabel = false] | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/ScopeOfPatternVariableDeclarations.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/ScopeOfPatternVariableDeclarations.txt index 34fed8bb67..ee01695dd4 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/ScopeOfPatternVariableDeclarations.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java21/ScopeOfPatternVariableDeclarations.txt @@ -14,7 +14,7 @@ | +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = true] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "obj", @Name = "obj", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchFallthroughBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Character"] @@ -34,7 +34,7 @@ | | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Ding!", @Empty = false, @Image = "\"Ding!\"", @Length = 5, @LiteralText = "\"Ding!\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | | +- BreakStatement[@Label = null] | +- SwitchFallthroughBranch[@Default = true] - | +- SwitchLabel[@Default = true] + | +- SwitchLabel[@Default = true, @PatternLabel = false] | +- BreakStatement[@Label = null] +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Name = "testSwitchRule", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] | +- ModifierList[@EffectiveModifiers = (JModifier.STATIC), @ExplicitModifiers = (JModifier.STATIC)] @@ -48,7 +48,7 @@ | +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Character"] @@ -76,7 +76,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "Character", @Empty = false, @Image = "\"Character\"", @Length = 9, @LiteralText = "\"Character\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Integer"] @@ -91,7 +91,7 @@ | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "i", @Name = "i", @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArgumentList[@Empty = true, @Size = 0] | +- SwitchArrowBranch[@Default = true] - | +- SwitchLabel[@Default = true] + | +- SwitchLabel[@Default = true, @PatternLabel = false] | +- Block[@Empty = false, @Size = 1, @containsComment = false] | +- BreakStatement[@Label = null] +- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Name = "test2", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true] @@ -106,7 +106,7 @@ | +- SwitchStatement[@DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = true] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchFallthroughBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Character"] @@ -147,7 +147,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "character", @Empty = false, @Image = "\"character\"", @Length = 9, @LiteralText = "\"character\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchFallthroughBranch[@Default = true] - | +- SwitchLabel[@Default = true] + | +- SwitchLabel[@Default = true, @PatternLabel = false] | +- ExpressionStatement[] | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22/Jep456_UnnamedPatternsAndVariables.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22/Jep456_UnnamedPatternsAndVariables.txt index e77a4d2574..06b6a2128c 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22/Jep456_UnnamedPatternsAndVariables.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22/Jep456_UnnamedPatternsAndVariables.txt @@ -181,7 +181,7 @@ | +- SwitchStatement[@DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "b", @Name = "b", @ParenthesisDepth = 0, @Parenthesized = false] | | +- SwitchArrowBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | | +- RecordPattern[] | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Box"] | | | | +- PatternList[@Empty = false, @Size = 1] @@ -193,7 +193,7 @@ | | | +- ArgumentList[@Empty = false, @Size = 1] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "b", @Name = "b", @ParenthesisDepth = 0, @Parenthesized = false] | | +- SwitchArrowBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | | +- RecordPattern[] | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Box"] | | | | +- PatternList[@Empty = false, @Size = 1] @@ -205,7 +205,7 @@ | | | +- ArgumentList[@Empty = false, @Size = 1] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "b", @Name = "b", @ParenthesisDepth = 0, @Parenthesized = false] | | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- RecordPattern[] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Box"] | | | +- PatternList[@Empty = false, @Size = 1] @@ -218,7 +218,7 @@ | +- SwitchStatement[@DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "b", @Name = "b", @ParenthesisDepth = 0, @Parenthesized = false] | | +- SwitchArrowBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | | +- RecordPattern[] | | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Box"] | | | | | +- PatternList[@Empty = false, @Size = 1] @@ -237,7 +237,7 @@ | | | +- ArgumentList[@Empty = false, @Size = 1] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "b", @Name = "b", @ParenthesisDepth = 0, @Parenthesized = false] | | +- SwitchArrowBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | | +- RecordPattern[] | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Box"] | | | | +- PatternList[@Empty = false, @Size = 1] @@ -248,7 +248,7 @@ | | | +- MethodCall[@CompileTimeConstant = false, @Image = "stopProcessing", @MethodName = "stopProcessing", @ParenthesisDepth = 0, @Parenthesized = false] | | | +- ArgumentList[@Empty = true, @Size = 0] | | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- RecordPattern[] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Box"] | | | +- PatternList[@Empty = false, @Size = 1] @@ -264,7 +264,7 @@ | +- SwitchStatement[@DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "b", @Name = "b", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- RecordPattern[] | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Box"] | | | | +- PatternList[@Empty = false, @Size = 1] @@ -287,7 +287,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "b", @Name = "b", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | +- SwitchLabel[@Default = false] + | +- SwitchLabel[@Default = false, @PatternLabel = true] | | +- RecordPattern[] | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Box"] | | +- PatternList[@Empty = false, @Size = 1] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep447_StatementsBeforeSuper.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep447_StatementsBeforeSuper.txt index 7490fc68a2..9fa3cd2810 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep447_StatementsBeforeSuper.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java22p/Jep447_StatementsBeforeSuper.txt @@ -105,7 +105,7 @@ | | +- SwitchExpression[@CompileTimeConstant = false, @DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "publicKey", @Name = "publicKey", @ParenthesisDepth = 0, @Parenthesized = false] | | +- SwitchArrowBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "RSAKey"] @@ -119,7 +119,7 @@ | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "StandardCharsets"] | | +- SwitchArrowBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "DSAPublicKey"] @@ -133,7 +133,7 @@ | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "StandardCharsets"] | | +- SwitchArrowBranch[@Default = true] - | | +- SwitchLabel[@Default = true] + | | +- SwitchLabel[@Default = true, @PatternLabel = false] | | +- ArrayAllocation[@ArrayDepth = 1, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArrayType[@ArrayDepth = 1] | | +- PrimitiveType[@Kind = PrimitiveTypeKind.BYTE] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java23p/Jep455_PrimitiveTypesInPatternsInstanceofAndSwitch.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java23p/Jep455_PrimitiveTypesInPatternsInstanceofAndSwitch.txt index c80a09fff6..850597a25e 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java23p/Jep455_PrimitiveTypesInPatternsInstanceofAndSwitch.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java23p/Jep455_PrimitiveTypesInPatternsInstanceofAndSwitch.txt @@ -347,7 +347,7 @@ | +- SwitchStatement[@DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = true] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "i", @Name = "i", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchFallthroughBranch[@Default = false] - | +- SwitchLabel[@Default = false] + | +- SwitchLabel[@Default = false, @PatternLabel = true] | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | +- PrimitiveType[@Kind = PrimitiveTypeKind.DOUBLE] @@ -381,11 +381,11 @@ | | +- SwitchExpression[@CompileTimeConstant = false, @DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "v", @Name = "v", @ParenthesisDepth = 0, @Parenthesized = false] | | +- SwitchArrowBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = true, @Image = "0f", @IntLiteral = false, @Integral = false, @LiteralText = "0f", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 0.0, @ValueAsFloat = 0.0, @ValueAsInt = 0, @ValueAsLong = 0] | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = true, @Image = "5f", @IntLiteral = false, @Integral = false, @LiteralText = "5f", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 5.0, @ValueAsFloat = 5.0, @ValueAsInt = 5, @ValueAsLong = 5] | | +- SwitchArrowBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | | | +- PrimitiveType[@Kind = PrimitiveTypeKind.FLOAT] @@ -398,7 +398,7 @@ | | | +- NumericLiteral[@Base = 10, @CompileTimeConstant = true, @DoubleLiteral = false, @FloatLiteral = true, @Image = "6f", @IntLiteral = false, @Integral = false, @LiteralText = "6f", @LongLiteral = false, @ParenthesisDepth = 0, @Parenthesized = false, @ValueAsDouble = 6.0, @ValueAsFloat = 6.0, @ValueAsInt = 6, @ValueAsLong = 6] | | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "x", @Name = "x", @ParenthesisDepth = 0, @Parenthesized = false] | | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | +- PrimitiveType[@Kind = PrimitiveTypeKind.FLOAT] @@ -424,7 +424,7 @@ | +- SwitchStatement[@DefaultCase = false, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false] | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "b", @Name = "b", @ParenthesisDepth = 0, @Parenthesized = false] | +- SwitchArrowBranch[@Default = false] - | | +- SwitchLabel[@Default = false] + | | +- SwitchLabel[@Default = false, @PatternLabel = false] | | | +- BooleanLiteral[@CompileTimeConstant = true, @LiteralText = "true", @ParenthesisDepth = 0, @Parenthesized = false, @True = true] | | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] @@ -433,7 +433,7 @@ | | +- ArgumentList[@Empty = false, @Size = 1] | | +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "b was true", @Empty = false, @Image = "\"b was true\"", @Length = 10, @LiteralText = "\"b was true\"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false] | +- SwitchArrowBranch[@Default = false] - | +- SwitchLabel[@Default = false] + | +- SwitchLabel[@Default = false, @PatternLabel = false] | | +- BooleanLiteral[@CompileTimeConstant = true, @LiteralText = "false", @ParenthesisDepth = 0, @Parenthesized = false, @True = false] | +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false] | +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false] diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java23p/Jep482_FlexibleConstructorBodies.txt b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java23p/Jep482_FlexibleConstructorBodies.txt index 549c591ece..a796c0b585 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java23p/Jep482_FlexibleConstructorBodies.txt +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/java23p/Jep482_FlexibleConstructorBodies.txt @@ -105,7 +105,7 @@ | | +- SwitchExpression[@CompileTimeConstant = false, @DefaultCase = true, @EnumSwitch = false, @ExhaustiveEnumSwitch = false, @FallthroughSwitch = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "publicKey", @Name = "publicKey", @ParenthesisDepth = 0, @Parenthesized = false] | | +- SwitchArrowBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "RSAKey"] @@ -119,7 +119,7 @@ | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "StandardCharsets"] | | +- SwitchArrowBranch[@Default = false] - | | | +- SwitchLabel[@Default = false] + | | | +- SwitchLabel[@Default = false, @PatternLabel = true] | | | | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE] | | | | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()] | | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "DSAPublicKey"] @@ -133,7 +133,7 @@ | | | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "StandardCharsets"] | | +- SwitchArrowBranch[@Default = true] - | | +- SwitchLabel[@Default = true] + | | +- SwitchLabel[@Default = true, @PatternLabel = false] | | +- ArrayAllocation[@ArrayDepth = 1, @CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false] | | +- ArrayType[@ArrayDepth = 1] | | +- PrimitiveType[@Kind = PrimitiveTypeKind.BYTE] From 90f436fd2861fc25b05fa6640be3579ad68f2170 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 4 Oct 2024 16:17:27 +0200 Subject: [PATCH 08/52] [java] TooFewBranchesForSwitch should ignore Pattern Matching Fixes #5249 --- docs/pages/release_notes.md | 3 +++ .../resources/category/java/performance.xml | 2 ++ .../xml/TooFewBranchesForASwitchStatement.xml | 22 +++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 197b7a4aec..f826710bdf 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -34,6 +34,9 @@ The old rule names still work but are deprecated. * [#4532](https://github.com/pmd/pmd/issues/4532): \[java] Rule misnomer for JUnit* rules * java-errorprone * [#5067](https://github.com/pmd/pmd/issues/5067): \[java] CloseResource: False positive for FileSystems.getDefault() +* java-performance + * [#5249](https://github.com/pmd/pmd/issues/5249): \[java] TooFewBranchesForASwitchStatement false positive for Pattern Matching + * [#....](https://github.com/pmd/pmd/issues/....): \[java] TooFewBranchesForASwitchStatement should consider Switch Expressions ### 🚨 API Changes * java-bestpractices diff --git a/pmd-java/src/main/resources/category/java/performance.xml b/pmd-java/src/main/resources/category/java/performance.xml index 376b536499..22a2ec1c4f 100644 --- a/pmd-java/src/main/resources/category/java/performance.xml +++ b/pmd-java/src/main/resources/category/java/performance.xml @@ -625,6 +625,8 @@ if-else statement to increase code readability. diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForASwitchStatement.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForASwitchStatement.xml index 006c56c1e5..bea0d83aa6 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForASwitchStatement.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForASwitchStatement.xml @@ -69,4 +69,26 @@ public class ValidSwitch { } ]]> + + + [java] TooFewBranchesForASwitchStatement false positive for Pattern Matching + 0 + System.out.println("a"); + } + } + + public void simpleSwitchExpression(S s) { + String result = switch(s) { + case A a -> "a"; + }; + } +} +]]> + From b87944a565cd8c6e91eb22dc43dcae7ed3a1953e Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 4 Oct 2024 16:22:59 +0200 Subject: [PATCH 09/52] [java] TooFewBranchesForSwitch should consider Switch Expressions Fixes #5250 --- docs/pages/release_notes.md | 2 +- .../resources/category/java/performance.xml | 2 +- .../xml/TooFewBranchesForASwitchStatement.xml | 20 ++++++++++++++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index f826710bdf..d0382529a6 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -36,7 +36,7 @@ The old rule names still work but are deprecated. * [#5067](https://github.com/pmd/pmd/issues/5067): \[java] CloseResource: False positive for FileSystems.getDefault() * java-performance * [#5249](https://github.com/pmd/pmd/issues/5249): \[java] TooFewBranchesForASwitchStatement false positive for Pattern Matching - * [#....](https://github.com/pmd/pmd/issues/....): \[java] TooFewBranchesForASwitchStatement should consider Switch Expressions + * [#5250](https://github.com/pmd/pmd/issues/5250): \[java] TooFewBranchesForASwitchStatement should consider Switch Expressions ### 🚨 API Changes * java-bestpractices diff --git a/pmd-java/src/main/resources/category/java/performance.xml b/pmd-java/src/main/resources/category/java/performance.xml index 22a2ec1c4f..bda8573382 100644 --- a/pmd-java/src/main/resources/category/java/performance.xml +++ b/pmd-java/src/main/resources/category/java/performance.xml @@ -624,7 +624,7 @@ if-else statement to increase code readability. diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForASwitchStatement.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForASwitchStatement.xml index bea0d83aa6..10dbb0081f 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForASwitchStatement.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForASwitchStatement.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests http://pmd.sourceforge.net/rule-tests_1_0_0.xsd"> - Only one case, this is useless + Switch Statement with only one case, not ok 3 1 + + Switch Expression with only one case, not ok + 3 + 1 + + + Even two branches is not enough for a switch statement 3 From 855e5175d48a68801a2dada88584e85fe847e3a8 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 4 Oct 2024 16:29:37 +0200 Subject: [PATCH 10/52] [java] Renamed rule TooFewBranchesForSwitch as it consider Switch Expressions now additionally to Switch Statements. --- docs/pages/release_notes.md | 21 +++++++++++-------- .../resources/category/java/performance.xml | 8 +++++-- ....java => TooFewBranchesForSwitchTest.java} | 2 +- ...tement.xml => TooFewBranchesForSwitch.xml} | 0 4 files changed, 19 insertions(+), 12 deletions(-) rename pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/performance/{TooFewBranchesForASwitchStatementTest.java => TooFewBranchesForSwitchTest.java} (77%) rename pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/{TooFewBranchesForASwitchStatement.xml => TooFewBranchesForSwitch.xml} (100%) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index d0382529a6..3856b7640d 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -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 diff --git a/pmd-java/src/main/resources/category/java/performance.xml b/pmd-java/src/main/resources/category/java/performance.xml index bda8573382..4c0d2fe00c 100644 --- a/pmd-java/src/main/resources/category/java/performance.xml +++ b/pmd-java/src/main/resources/category/java/performance.xml @@ -607,16 +607,20 @@ private String baz() {
- + + + externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_performance.html#toofewbranchesforswitch"> 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. 3 diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/performance/TooFewBranchesForASwitchStatementTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/performance/TooFewBranchesForSwitchTest.java similarity index 77% rename from pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/performance/TooFewBranchesForASwitchStatementTest.java rename to pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/performance/TooFewBranchesForSwitchTest.java index 3916959a96..1787e14681 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/performance/TooFewBranchesForASwitchStatementTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/performance/TooFewBranchesForSwitchTest.java @@ -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 } diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForASwitchStatement.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForSwitch.xml similarity index 100% rename from pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForASwitchStatement.xml rename to pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForSwitch.xml From d9db4dbcabebc8b4e3f7fbecb7a6a7b1ac4e45c2 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 5 Oct 2024 10:19:03 +0200 Subject: [PATCH 11/52] [java] Rename TooFewBranchesForSwitch in quickstart.xml --- pmd-java/src/main/resources/rulesets/java/quickstart.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmd-java/src/main/resources/rulesets/java/quickstart.xml b/pmd-java/src/main/resources/rulesets/java/quickstart.xml index 3ac03a493c..28bd28467c 100644 --- a/pmd-java/src/main/resources/rulesets/java/quickstart.xml +++ b/pmd-java/src/main/resources/rulesets/java/quickstart.xml @@ -307,7 +307,7 @@ - + From 1f31f771ad14d8a89920a208995b10d9142bc201 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 5 Oct 2024 10:31:40 +0200 Subject: [PATCH 12/52] [java] SwitchDensity - more tests with (record) patterns --- .../java/rule/design/xml/SwitchDensity.xml | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/design/xml/SwitchDensity.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/design/xml/SwitchDensity.xml index 4216e0073c..1c3c21bf4d 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/design/xml/SwitchDensity.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/design/xml/SwitchDensity.xml @@ -181,4 +181,78 @@ public class SwitchDensityPattern { } ]]> + + + [java] SwitchDensity with pattern matching #5030 + 4 + 1 + 0 -> + { + System.err.println("I am a fish."); + System.err.println("I am a fish."); + System.err.println("I am a fish."); + System.err.println("I am a fish."); + System.err.println("I am a fish."); + } + case Integer i -> + { + System.err.println("I am not a fish."); + System.err.println("I am not a fish."); + System.err.println("I am not a fish."); + System.err.println("I am not a fish."); + System.err.println("I am not a fish."); + System.err.println("I am not a fish."); + } + default -> + { + System.err.println("default"); + } + } + } +} + ]]> + + + + Switch with Record Pattern, ok + 0 + System.out.println(a); + } + } +} +]]> + + + + Switch with Record Pattern, not ok + 4 + 1 + { + System.out.println(a); + System.out.println(a); + System.out.println(a); + System.out.println(a); + System.out.println(a); + } + } + } +} +]]> + From 13cc79af62d060bff491ff33cddf918cad0cb6ae Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 5 Oct 2024 10:36:39 +0200 Subject: [PATCH 13/52] [java] TooFewBranchesForSwitch - also ignore record pattern --- .../resources/category/java/performance.xml | 2 +- .../xml/TooFewBranchesForSwitch.xml | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/pmd-java/src/main/resources/category/java/performance.xml b/pmd-java/src/main/resources/category/java/performance.xml index 4c0d2fe00c..2a6d218354 100644 --- a/pmd-java/src/main/resources/category/java/performance.xml +++ b/pmd-java/src/main/resources/category/java/performance.xml @@ -630,7 +630,7 @@ Note: This rule was named TooFewBranchesForASwitchStatement before PMD 7.7.0. diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForSwitch.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForSwitch.xml index 10dbb0081f..2af77f0e74 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForSwitch.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForSwitch.xml @@ -89,7 +89,7 @@ public class ValidSwitch { - [java] TooFewBranchesForASwitchStatement false positive for Pattern Matching + [java] TooFewBranchesForASwitchStatement false positive for Pattern Matching #5249 0 + + + + Record patterns are ignored, too #5249 + 0 + System.out.println(a); + } + } +} ]]> From 59403fc9e145aac5c5c9a9d4fbf0474a725c0f3c Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 5 Oct 2024 10:39:55 +0200 Subject: [PATCH 14/52] [java] SwitchStmtsShouldHaveDefault - also ignore record pattern --- .../resources/category/java/bestpractices.xml | 4 ++-- .../xml/SwitchStmtsShouldHaveDefault.xml | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/pmd-java/src/main/resources/category/java/bestpractices.xml b/pmd-java/src/main/resources/category/java/bestpractices.xml index aa965d9f67..58fea8b30b 100644 --- a/pmd-java/src/main/resources/category/java/bestpractices.xml +++ b/pmd-java/src/main/resources/category/java/bestpractices.xml @@ -1178,8 +1178,8 @@ class SomeTestClass { diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/SwitchStmtsShouldHaveDefault.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/SwitchStmtsShouldHaveDefault.xml index e28cfe5b9d..145739199e 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/SwitchStmtsShouldHaveDefault.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/SwitchStmtsShouldHaveDefault.xml @@ -313,6 +313,22 @@ public class Example2 { } } } +]]> + + + + With Record Patterns #4813 + 0 + System.out.println(a); + } + } +} ]]> From 6f081e111a1eae05555d71e85a7b994cc3b643d8 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 5 Oct 2024 10:41:10 +0200 Subject: [PATCH 15/52] Update pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForSwitch.xml --- .../lang/java/rule/performance/xml/TooFewBranchesForSwitch.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForSwitch.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForSwitch.xml index 2af77f0e74..502c470bc2 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForSwitch.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForSwitch.xml @@ -23,7 +23,7 @@ public class DumbSwitch { - Switch Expression with only one case, not ok + Switch Expression with only one case, not ok #5250 3 1 Date: Sat, 5 Oct 2024 11:00:13 +0200 Subject: [PATCH 16/52] [java] Rename rule DefaultLabelNotLastInSwitch - as it applies to both switch statements and switch expressions - extend the test cases to cover new java syntax Note: For patterns in switch, the java compiler already makes sure, that default is the last case. --- docs/pages/release_notes.md | 21 +-- .../resources/category/java/bestpractices.xml | 12 +- .../resources/rulesets/java/quickstart.xml | 2 +- ...a => DefaultLabelNotLastInSwitchTest.java} | 2 +- .../xml/DefaultLabelNotLastInSwitch.xml | 136 ++++++++++++++++++ .../xml/DefaultLabelNotLastInSwitchStmt.xml | 59 -------- 6 files changed, 157 insertions(+), 75 deletions(-) rename pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/{DefaultLabelNotLastInSwitchStmtTest.java => DefaultLabelNotLastInSwitchTest.java} (78%) create mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/DefaultLabelNotLastInSwitch.xml delete mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/DefaultLabelNotLastInSwitchStmt.xml diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 197b7a4aec..00fa297731 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -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/bestpractices/DefaultLabelNotLastInSwitch %} (Java Best Practices) has been renamed from `DefaultLabelNotLastInSwitch`, as it also + applies to Switch Expressions. The old rule names still work but are deprecated. @@ -43,7 +44,7 @@ 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. - + * The old rule name `DefaultLabelNotLastInSwitch` has been deprecated. Use the new name {% rule java/bestpractices/DefaultLabelNotLastInSwitch %} instead. ### ✨ Merged pull requests * [#4965](https://github.com/pmd/pmd/pull/4965): \[java] Rename JUnit rules with overly restrictive names - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) diff --git a/pmd-java/src/main/resources/category/java/bestpractices.xml b/pmd-java/src/main/resources/category/java/bestpractices.xml index 03b23ad1ca..834651971c 100644 --- a/pmd-java/src/main/resources/category/java/bestpractices.xml +++ b/pmd-java/src/main/resources/category/java/bestpractices.xml @@ -457,14 +457,18 @@ public interface YetAnotherConstantInterface { - + + + externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#defaultlabelnotlastinswitch"> -By convention, the default label should be the last label in a switch statement. +By convention, the default label should be the last label in a switch statement or switch expression. + +Note: This rule has been renamed from "DefaultLabelNotLastInSwitchStmt" with PMD 7.7.0. 3 diff --git a/pmd-java/src/main/resources/rulesets/java/quickstart.xml b/pmd-java/src/main/resources/rulesets/java/quickstart.xml index 3ac03a493c..a195090891 100644 --- a/pmd-java/src/main/resources/rulesets/java/quickstart.xml +++ b/pmd-java/src/main/resources/rulesets/java/quickstart.xml @@ -18,7 +18,7 @@ - + diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/DefaultLabelNotLastInSwitchStmtTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/DefaultLabelNotLastInSwitchTest.java similarity index 78% rename from pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/DefaultLabelNotLastInSwitchStmtTest.java rename to pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/DefaultLabelNotLastInSwitchTest.java index b316a1881f..a012153e0e 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/DefaultLabelNotLastInSwitchStmtTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/DefaultLabelNotLastInSwitchTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.java.rule.bestpractices; import net.sourceforge.pmd.test.PmdRuleTst; -class DefaultLabelNotLastInSwitchStmtTest extends PmdRuleTst { +class DefaultLabelNotLastInSwitchTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/DefaultLabelNotLastInSwitch.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/DefaultLabelNotLastInSwitch.xml new file mode 100644 index 0000000000..5212dbe022 --- /dev/null +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/DefaultLabelNotLastInSwitch.xml @@ -0,0 +1,136 @@ + + + + + ok + 0 + + + + + bad + 1 + + + + + ok, no default + 0 + + + + + switch expression, ok + 0 + + + + + switch expression, not ok + 1 + + + + + switch arrow, ok + 0 + System.out.println("a"); + default -> System.out.println("default"); + } + } +} + ]]> + + + + switch arrow, not ok + 1 + System.out.println("a"); + default -> System.out.println("default"); + case 2 -> System.out.println("b"); + } + } +} + ]]> + + + + switch with pattern and default case, ok + 0 + + + diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/DefaultLabelNotLastInSwitchStmt.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/DefaultLabelNotLastInSwitchStmt.xml deleted file mode 100644 index df892c6141..0000000000 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/DefaultLabelNotLastInSwitchStmt.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - ok - 0 - - - - - bad - 1 - - - - - ok, no default - 0 - - - From 079eb238b9bfbf90992b3cfae4860f34971478d8 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 5 Oct 2024 11:19:53 +0200 Subject: [PATCH 17/52] [java] NonCaseLabelInSwitch - support switch expressions Rename rule from NonCaseLabelInSwitchStatement - as it applies to both switch statements and switch expressions - extend the test cases to cover new java syntax --- docs/pages/release_notes.md | 22 +-- .../resources/category/java/errorprone.xml | 13 +- .../resources/rulesets/java/quickstart.xml | 2 +- ...est.java => NonCaseLabelInSwitchTest.java} | 2 +- .../errorprone/xml/NonCaseLabelInSwitch.xml | 155 ++++++++++++++++++ .../xml/NonCaseLabelInSwitchStatement.xml | 43 ----- 6 files changed, 177 insertions(+), 60 deletions(-) rename pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/errorprone/{NonCaseLabelInSwitchStatementTest.java => NonCaseLabelInSwitchTest.java} (78%) create mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/NonCaseLabelInSwitch.xml delete mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/NonCaseLabelInSwitchStatement.xml diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 197b7a4aec..16315bf5b2 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -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/errorprone/NonCaseLabelInSwitch %} (Java Error Prone) has been renamed from `NonCaseLabelInSwitchStatement` as it also applies + to Switch Expressions. The old rule names still work but are deprecated. @@ -43,7 +44,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-errorprone + * The old rule name `NonCaseLabelInSwitchStatement` has been deprecated. Use the new name {% rule java/errorprone/NonCaseLabelInSwitch %} instead. ### ✨ Merged pull requests * [#4965](https://github.com/pmd/pmd/pull/4965): \[java] Rename JUnit rules with overly restrictive names - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) diff --git a/pmd-java/src/main/resources/category/java/errorprone.xml b/pmd-java/src/main/resources/category/java/errorprone.xml index 1f9ed37765..875c5d8157 100644 --- a/pmd-java/src/main/resources/category/java/errorprone.xml +++ b/pmd-java/src/main/resources/category/java/errorprone.xml @@ -2185,20 +2185,24 @@ public class Foo { - + + -A non-case label (e.g. a named break/continue label) was present in a switch statement. +A non-case label (e.g. a named break/continue label) was present in a switch statement or switch expression. This is legal, but confusing. It is easy to mix up the case labels and the non-case labels. + +Note: This rule was renamed from `NonCaseLabelInSwitchStatement` with PMD 7.7.0. 3 - //SwitchStatement//LabeledStatement + //(SwitchStatement|SwitchExpression)//LabeledStatement @@ -2208,7 +2212,6 @@ public class Foo { switch (a) { case 1: // do something - break; mylabel: // this is legal, but confusing! break; default: diff --git a/pmd-java/src/main/resources/rulesets/java/quickstart.xml b/pmd-java/src/main/resources/rulesets/java/quickstart.xml index 3ac03a493c..3f8b129015 100644 --- a/pmd-java/src/main/resources/rulesets/java/quickstart.xml +++ b/pmd-java/src/main/resources/rulesets/java/quickstart.xml @@ -243,7 +243,7 @@ - + diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/errorprone/NonCaseLabelInSwitchStatementTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/errorprone/NonCaseLabelInSwitchTest.java similarity index 78% rename from pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/errorprone/NonCaseLabelInSwitchStatementTest.java rename to pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/errorprone/NonCaseLabelInSwitchTest.java index 9d914a9552..8644b8d91c 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/errorprone/NonCaseLabelInSwitchStatementTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/errorprone/NonCaseLabelInSwitchTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.java.rule.errorprone; import net.sourceforge.pmd.test.PmdRuleTst; -class NonCaseLabelInSwitchStatementTest extends PmdRuleTst { +class NonCaseLabelInSwitchTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/NonCaseLabelInSwitch.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/NonCaseLabelInSwitch.xml new file mode 100644 index 0000000000..d40af2f6c9 --- /dev/null +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/NonCaseLabelInSwitch.xml @@ -0,0 +1,155 @@ + + + + + label inside switch statement, not ok + 1 + 5 + + + + + label inside switch expression, not ok + 1 + 5 + + + + + only cases in switch statement, ok + 0 + + + + + only cases in switch expression, ok + 0 + + + + + label in switch statement with arrow syntax, not ok + 1 + 6 + { + int y=8; + somelabel: + break; + } + default -> { + int j=8; + } + } + } +} +]]> + + + + label in switch expression with arrow syntax, not ok + 1 + 5 + { int y=8; + somelabel: + yield y; + } + default -> { + int j=8; + yield j; + } + }; + } +} +]]> + + + + only cases in switch stmt/expr with arrow syntax, ok + 0 + { + int y=8; + break; + } + default -> { + int j=8; + } + } + } + void barArrow(int x) { + x = switch (x) { + case 2 -> { int y=8; + yield y; + } + default -> { + int j=8; + yield j; + } + }; + } +} +]]> + + diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/NonCaseLabelInSwitchStatement.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/NonCaseLabelInSwitchStatement.xml deleted file mode 100644 index b2ba4cecd0..0000000000 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/NonCaseLabelInSwitchStatement.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - label inside switch - 1 - 6 - - - - - ok - 0 - - - From 5ecc29245beac565bc9708b89691cf7e60703916 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 5 Oct 2024 11:37:45 +0200 Subject: [PATCH 18/52] Fix externalInfoUrl after rename --- pmd-java/src/main/resources/category/java/errorprone.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmd-java/src/main/resources/category/java/errorprone.xml b/pmd-java/src/main/resources/category/java/errorprone.xml index 875c5d8157..98c35472e9 100644 --- a/pmd-java/src/main/resources/category/java/errorprone.xml +++ b/pmd-java/src/main/resources/category/java/errorprone.xml @@ -2192,7 +2192,7 @@ public class Foo { since="1.5" message="A non-case label was present in a switch statement or expression" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" - externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#noncaselabelinswitchstatement"> + externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#noncaselabelinswitch"> A non-case label (e.g. a named break/continue label) was present in a switch statement or switch expression. This is legal, but confusing. It is easy to mix up the case labels and the non-case labels. From 377670f267a48108dda31f2f10a9b78bb2374f97 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sun, 6 Oct 2024 18:48:47 +0200 Subject: [PATCH 19/52] [doc] Update release notes (#5257) --- docs/pages/release_notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 16315bf5b2..85fa3914f0 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -35,6 +35,7 @@ The old rule names still work but are deprecated. * [#4532](https://github.com/pmd/pmd/issues/4532): \[java] Rule misnomer for JUnit* rules * java-errorprone * [#5067](https://github.com/pmd/pmd/issues/5067): \[java] CloseResource: False positive for FileSystems.getDefault() + * [#5257](https://github.com/pmd/pmd/issues/5257): \[java] NonCaseLabelInSwitch should consider switch expressions ### 🚨 API Changes * java-bestpractices From ff1b9b2cdde7702f4df34bd55d5d7049a9e06b2a Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Tue, 8 Oct 2024 17:15:18 +0200 Subject: [PATCH 20/52] [java] SwitchStmtsShouldHaveDefault - test for multiple case constants --- .../xml/SwitchStmtsShouldHaveDefault.xml | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/SwitchStmtsShouldHaveDefault.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/SwitchStmtsShouldHaveDefault.xml index 145739199e..cd13ce5dc9 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/SwitchStmtsShouldHaveDefault.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/SwitchStmtsShouldHaveDefault.xml @@ -329,6 +329,39 @@ public class SwitchWithRecordPattern { } } } +]]> + + + + Multiple Case Constants + 0 + System.out.println("a or b"); + case C -> System.out.println("c"); + } + String s = switch(e) { + case A,B -> "a or b"; + case C -> "c"; + }; + System.out.println(s); + } +} ]]> From 07840cace2d8b375bbc22331d864d8a0b9375b27 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Tue, 8 Oct 2024 17:26:18 +0200 Subject: [PATCH 21/52] [java] Rename rule SwitchStmtsShouldHaveDefault to NonExhaustiveSwitch Fixes #4286 --- docs/pages/release_notes.md | 21 +++--- .../resources/category/java/bestpractices.xml | 68 ++++++++++--------- .../resources/rulesets/java/quickstart.xml | 2 +- ...Test.java => NonExhaustiveSwitchTest.java} | 2 +- ...aveDefault.xml => NonExhaustiveSwitch.xml} | 0 5 files changed, 49 insertions(+), 44 deletions(-) rename pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/{SwitchStmtsShouldHaveDefaultTest.java => NonExhaustiveSwitchTest.java} (79%) rename pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/{SwitchStmtsShouldHaveDefault.xml => NonExhaustiveSwitch.xml} (100%) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 197b7a4aec..aac6ab6801 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -17,21 +17,23 @@ 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/bestpractices/NonExhaustiveSwitch %} (Java Best Practices) has been renamed from `SwitchStmtsShouldHaveDefault`. The old rule names still work but are deprecated. ### 🐛 Fixed Issues * java * [#4532](https://github.com/pmd/pmd/issues/4532): \[java] Rule misnomer for JUnit* rules +* java-bestpractices + * [#4286](https://github.com/pmd/pmd/issues/4286): \[java] Rename rule SwitchStmtsShouldHaveDefault to NonExhaustiveSwitch * java-errorprone * [#5067](https://github.com/pmd/pmd/issues/5067): \[java] CloseResource: False positive for FileSystems.getDefault() @@ -43,6 +45,7 @@ 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. + * The old rule name `SwitchStmtsShouldHaveDefault` has been deprecated. USe the new name {%rule java/bestpractices/NonExhaustiveSwitch %} instead. ### ✨ Merged pull requests diff --git a/pmd-java/src/main/resources/category/java/bestpractices.xml b/pmd-java/src/main/resources/category/java/bestpractices.xml index 03b23ad1ca..14ae96fcdc 100644 --- a/pmd-java/src/main/resources/category/java/bestpractices.xml +++ b/pmd-java/src/main/resources/category/java/bestpractices.xml @@ -904,6 +904,40 @@ public class SecureSystem { + + + Switch statements should be exhaustive, to make their control flow + easier to follow. This can be achieved by adding a `default` case, or, + if the switch is on an enum type, by ensuring there is one switch branch + for each enum constant. + + 3 + + + + + + + + + + - - - Switch statements should be exhaustive, to make their control flow - easier to follow. This can be achieved by adding a `default` case, or, - if the switch is on an enum type, by ensuring there is one switch branch - for each enum constant. - - 3 - - - - - - - - - + + @@ -37,7 +38,6 @@ - diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/SwitchStmtsShouldHaveDefaultTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/NonExhaustiveSwitchTest.java similarity index 79% rename from pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/SwitchStmtsShouldHaveDefaultTest.java rename to pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/NonExhaustiveSwitchTest.java index 1e413f1bde..2d7b18f754 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/SwitchStmtsShouldHaveDefaultTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/NonExhaustiveSwitchTest.java @@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.java.rule.bestpractices; import net.sourceforge.pmd.test.PmdRuleTst; -class SwitchStmtsShouldHaveDefaultTest extends PmdRuleTst { +class NonExhaustiveSwitchTest extends PmdRuleTst { // no additional unit tests } diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/SwitchStmtsShouldHaveDefault.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/NonExhaustiveSwitch.xml similarity index 100% rename from pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/SwitchStmtsShouldHaveDefault.xml rename to pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/NonExhaustiveSwitch.xml From c595fea83f7c8f089ce9d550c93b152b41c95c3a Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 11 Oct 2024 11:57:10 +0200 Subject: [PATCH 22/52] [apex] AvoidNonRestrictiveQueries: Fix regex for detecting LIMIT clause Fixes #5270 --- docs/pages/release_notes.md | 2 ++ .../AvoidNonRestrictiveQueriesRule.java | 2 +- .../xml/AvoidNonRestrictiveQueries.xml | 30 +++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 197b7a4aec..6da08b0c2c 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -30,6 +30,8 @@ after JUnit / JUnit 4, even when they applied to JUnit 5 and / or TestNG. The old rule names still work but are deprecated. ### 🐛 Fixed Issues +* apex-performance + * [#5270](https://github.com/pmd/pmd/issues/5270): \[apex] AvoidNonRestrictiveQueries when LIMIT is followed by bind expression * java * [#4532](https://github.com/pmd/pmd/issues/4532): \[java] Rule misnomer for JUnit* rules * java-errorprone diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidNonRestrictiveQueriesRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidNonRestrictiveQueriesRule.java index e62363eb7e..fd3c5bf392 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidNonRestrictiveQueriesRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidNonRestrictiveQueriesRule.java @@ -24,7 +24,7 @@ import net.sourceforge.pmd.lang.rule.RuleTargetSelector; import net.sourceforge.pmd.reporting.RuleContext; public class AvoidNonRestrictiveQueriesRule extends AbstractApexRule { - private static final Pattern RESTRICTIVE_PATTERN = Pattern.compile("(where\\s+)|(limit\\s+)", Pattern.CASE_INSENSITIVE); + private static final Pattern RESTRICTIVE_PATTERN = Pattern.compile("\\b(where|limit)\\b", Pattern.CASE_INSENSITIVE); private static final Pattern SELECT_OR_FIND_PATTERN = Pattern.compile("(select\\s+|find\\s+)", Pattern.CASE_INSENSITIVE); private static final Pattern SUB_QUERY_PATTERN = Pattern.compile("(?i)\\(\\s*select\\s+[^)]+\\)"); diff --git a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/performance/xml/AvoidNonRestrictiveQueries.xml b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/performance/xml/AvoidNonRestrictiveQueries.xml index 289a049261..c18ad9538a 100644 --- a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/performance/xml/AvoidNonRestrictiveQueries.xml +++ b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/rule/performance/xml/AvoidNonRestrictiveQueries.xml @@ -260,6 +260,36 @@ public class Something { .isEmpty(); } } +]]> + + + + [apex] AvoidNonRestrictiveQueries when LIMIT is followed by bind expression #5270 + 0 + getTwoAccounts() { + List result = [ + SELECT Id, Name FROM Account WITH SECURITY_ENFORCED + LIMIT:LIMIT_ACCOUNTS // note: no spaces... - false positive here + ]; + List result2 = [ + SELECT Id, Name FROM Account WITH SECURITY_ENFORCED + LIMIT :LIMIT_ACCOUNTS + ]; + List result3 = [ + SELECT Id, Name FROM Account WITH SECURITY_ENFORCED + LIMIT : LIMIT_ACCOUNTS + ]; + + // sosl: + List> searchList = [FIND 'map*' IN ALL FIELDS RETURNING Account (Id, Name), Contact, Opportunity, Lead LIMIT:LIMIT_ACCOUNTS]; + + return result; + } +} ]]> From 7ae31553257a5bf9bb9d31e40e9fcf86c5a33aad Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 11 Oct 2024 11:57:39 +0200 Subject: [PATCH 23/52] Add @thesunlover as a contributor --- .all-contributorsrc | 9 ++ docs/pages/pmd/projectdocs/credits.md | 171 +++++++++++++------------- 2 files changed, 95 insertions(+), 85 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 28d946f30a..6bde20ce77 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -7819,6 +7819,15 @@ "contributions": [ "bug" ] + }, + { + "login": "thesunlover", + "name": "Iskren Stanislavov", + "avatar_url": "https://avatars.githubusercontent.com/u/6734600?v=4", + "profile": "https://interop.io/", + "contributions": [ + "bug" + ] } ], "contributorsPerLine": 7, diff --git a/docs/pages/pmd/projectdocs/credits.md b/docs/pages/pmd/projectdocs/credits.md index 4795947746..6eb428996d 100644 --- a/docs/pages/pmd/projectdocs/credits.md +++ b/docs/pages/pmd/projectdocs/credits.md @@ -340,770 +340,771 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d Ishan Srivastava
Ishan Srivastava

🐛 + Iskren Stanislavov
Iskren Stanislavov

🐛 Ivan Vakhrushev
Ivan Vakhrushev

🐛 Ivano Guerini
Ivano Guerini

🐛 Ivar Andreas Bonsaksen
Ivar Andreas Bonsaksen

🐛 Ivo Šmíd
Ivo Šmíd

🐛 JJengility
JJengility

🐛 - Jake Hemmerle
Jake Hemmerle

🐛 + Jake Hemmerle
Jake Hemmerle

🐛 James Harrison
James Harrison

🐛 💻 Jamie Bisotti
Jamie Bisotti

🐛 Jan
Jan

🐛 Jan Aertgeerts
Jan Aertgeerts

💻 🐛 Jan Brümmer
Jan Brümmer

🐛 Jan Tříska
Jan Tříska

🐛 - Jan-Lukas Else
Jan-Lukas Else

🐛 + Jan-Lukas Else
Jan-Lukas Else

🐛 Jason Qiu
Jason Qiu

💻 📖 Jason Williams
Jason Williams

🐛 Jean-Paul Mayer
Jean-Paul Mayer

🐛 Jean-Simon Larochelle
Jean-Simon Larochelle

🐛 Jeff Bartolotta
Jeff Bartolotta

💻 🐛 Jeff Hube
Jeff Hube

💻 🐛 - Jeff Jensen
Jeff Jensen

🐛 + Jeff Jensen
Jeff Jensen

🐛 Jeff May
Jeff May

🐛 Jens Gerdes
Jens Gerdes

🐛 Jeroen Borgers
Jeroen Borgers

🐛 💻 📢 Jeroen Meijer
Jeroen Meijer

🐛 Jeroen van Wilgenburg
Jeroen van Wilgenburg

📖 Jerome Russ
Jerome Russ

🐛 - JerritEic
JerritEic

💻 📖 🐛 + JerritEic
JerritEic

💻 📖 🐛 Jiri Pejchal
Jiri Pejchal

🐛 Jithin Sunny
Jithin Sunny

🐛 Jiří Škorpil
Jiří Škorpil

🐛 Joao Machado
Joao Machado

🐛 Jochen Krauss
Jochen Krauss

🐛 Johan Hammar
Johan Hammar

🐛 - John Karp
John Karp

🐛 + John Karp
John Karp

🐛 John Zhang
John Zhang

🐛 John-Teng
John-Teng

💻 🐛 Jon Moroney
Jon Moroney

💻 🐛 Jonas Geiregat
Jonas Geiregat

🐛 Jonas Keßler
Jonas Keßler

🐛 Jonathan Wiesel
Jonathan Wiesel

💻 🐛 - Jordan
Jordan

🐛 + Jordan
Jordan

🐛 Jordi Llach
Jordi Llach

🐛 Jorge Solórzano
Jorge Solórzano

🐛 JorneVL
JorneVL

🐛 Jose Palafox
Jose Palafox

🐛 Jose Stovall
Jose Stovall

🐛 Joseph
Joseph

💻 - Joseph Heenan
Joseph Heenan

🐛 + Joseph Heenan
Joseph Heenan

🐛 Josh Feingold
Josh Feingold

💻 🐛 Josh Holthaus
Josh Holthaus

🐛 Joshua S Arquilevich
Joshua S Arquilevich

🐛 João Dinis Ferreira
João Dinis Ferreira

📖 João Ferreira
João Ferreira

💻 🐛 João Pedro Schmitt
João Pedro Schmitt

🐛 - Juan Martín Sotuyo Dodero
Juan Martín Sotuyo Dodero

💻 📖 🐛 🚧 + Juan Martín Sotuyo Dodero
Juan Martín Sotuyo Dodero

💻 📖 🐛 🚧 Juan Pablo Civile
Juan Pablo Civile

🐛 Julian Voronetsky
Julian Voronetsky

🐛 Julien
Julien

🐛 Julius
Julius

🐛 JustPRV
JustPRV

🐛 Justin Stroud
Justin Stroud

💻 - Jörn Huxhorn
Jörn Huxhorn

🐛 + Jörn Huxhorn
Jörn Huxhorn

🐛 KThompso
KThompso

🐛 Kai Amundsen
Kai Amundsen

🐛 Karel Vervaeke
Karel Vervaeke

🐛 Karl-Andero Mere
Karl-Andero Mere

🐛 Karl-Philipp Richter
Karl-Philipp Richter

🐛 Karsten Silz
Karsten Silz

🐛 - Kazuma Watanabe
Kazuma Watanabe

🐛 + Kazuma Watanabe
Kazuma Watanabe

🐛 Kev
Kev

🐛 Keve Müller
Keve Müller

🐛 Kevin Guerra
Kevin Guerra

💻 Kevin Jones
Kevin Jones

🐛 💻 Kevin Poorman
Kevin Poorman

🐛 Kevin Wayne
Kevin Wayne

🐛 - Kieran Black
Kieran Black

🐛 + Kieran Black
Kieran Black

🐛 Kirill Zubov
Kirill Zubov

🐛 Kirk Clemens
Kirk Clemens

💻 🐛 Klaus Hartl
Klaus Hartl

🐛 Koen Van Looveren
Koen Van Looveren

🐛 Kris Scheibe
Kris Scheibe

💻 🐛 Krystian Dabrowski
Krystian Dabrowski

🐛 💻 - Kunal Thanki
Kunal Thanki

🐛 + Kunal Thanki
Kunal Thanki

🐛 LaLucid
LaLucid

💻 Larry Diamond
Larry Diamond

💻 🐛 Lars Knickrehm
Lars Knickrehm

🐛 Laurent Bovet
Laurent Bovet

🐛 💻 Leo Gutierrez
Leo Gutierrez

🐛 LiGaOg
LiGaOg

💻 - Liam Sharp
Liam Sharp

🐛 + Liam Sharp
Liam Sharp

🐛 Lintsi
Lintsi

🐛 Linus Fernandes
Linus Fernandes

🐛 Lixon Lookose
Lixon Lookose

🐛 Logesh
Logesh

🐛 Lorenzo Gabriele
Lorenzo Gabriele

🐛 Loïc Ledoyen
Loïc Ledoyen

🐛 - Lucas
Lucas

🐛 + Lucas
Lucas

🐛 Lucas Silva
Lucas Silva

🐛 Lucas Soncini
Lucas Soncini

💻 🐛 Luis Alcantar
Luis Alcantar

💻 Lukas Gräf
Lukas Gräf

💻 Lukasz Slonina
Lukasz Slonina

🐛 Lukebray
Lukebray

🐛 - Lynn
Lynn

💻 🐛 + Lynn
Lynn

💻 🐛 Lyor Goldstein
Lyor Goldstein

🐛 MCMicS
MCMicS

🐛 Macarse
Macarse

🐛 Machine account for PMD
Machine account for PMD

💻 Maciek Siemczyk
Maciek Siemczyk

🐛 Maikel Steneker
Maikel Steneker

💻 🐛 - Maksim Moiseikin
Maksim Moiseikin

🐛 + Maksim Moiseikin
Maksim Moiseikin

🐛 Manfred Koch
Manfred Koch

🐛 Manuel Moya Ferrer
Manuel Moya Ferrer

💻 🐛 Manuel Ryan
Manuel Ryan

🐛 Marat Vyshegorodtsev
Marat Vyshegorodtsev

🐛 Marcel Härle
Marcel Härle

🐛 Marcello Fialho
Marcello Fialho

🐛 - Marcin Dąbrowski
Marcin Dąbrowski

💻 + Marcin Dąbrowski
Marcin Dąbrowski

💻 Marcin Rataj
Marcin Rataj

🐛 Marcono1234
Marcono1234

🐛 Mark Adamcin
Mark Adamcin

🐛 Mark Hall
Mark Hall

💻 🐛 Mark Kolich
Mark Kolich

🐛 Mark Pritchard
Mark Pritchard

🐛 - Markus Rathgeb
Markus Rathgeb

🐛 + Markus Rathgeb
Markus Rathgeb

🐛 Marquis Wang
Marquis Wang

🐛 MartGit
MartGit

🐛 Martin Feldsztejn
Martin Feldsztejn

🐛 Martin Lehmann
Martin Lehmann

🐛 Martin Spamer
Martin Spamer

🐛 Martin Tarjányi
Martin Tarjányi

🐛 - MatFl
MatFl

🐛 + MatFl
MatFl

🐛 Mateusz Stefanski
Mateusz Stefanski

🐛 Mathieu Gouin
Mathieu Gouin

🐛 MatiasComercio
MatiasComercio

💻 🐛 Matt Benson
Matt Benson

🐛 Matt De Poorter
Matt De Poorter

🐛 Matt Hargett
Matt Hargett

💻 💵 - Matt Harrah
Matt Harrah

🐛 + Matt Harrah
Matt Harrah

🐛 Matt Nelson
Matt Nelson

🐛 Matthew Amos
Matthew Amos

🐛 Matthew Duggan
Matthew Duggan

🐛 Matthew Hall
Matthew Hall

🐛 Matthew Rossner
Matthew Rossner

🐛 Matías Fraga
Matías Fraga

💻 🐛 - Maxime Robert
Maxime Robert

💻 🐛 + Maxime Robert
Maxime Robert

💻 🐛 MetaBF
MetaBF

🐛 Metin Dagcilar
Metin Dagcilar

🐛 Michael
Michael

🐛 Michael Bell
Michael Bell

🐛 Michael Bernstein
Michael Bernstein

🐛 Michael Clay
Michael Clay

🐛 - Michael Dombrowski
Michael Dombrowski

🐛 + Michael Dombrowski
Michael Dombrowski

🐛 Michael Hausegger
Michael Hausegger

🐛 Michael Hoefer
Michael Hoefer

🐛 Michael Kolesnikov
Michael Kolesnikov

🐛 Michael Möbius
Michael Möbius

🐛 Michael N. Lipp
Michael N. Lipp

🐛 Michael Pellegrini
Michael Pellegrini

🐛 - Michal Kordas
Michal Kordas

🐛 + Michal Kordas
Michal Kordas

🐛 Michał Borek
Michał Borek

🐛 Michał Kuliński
Michał Kuliński

🐛 Miguel Núñez Díaz-Montes
Miguel Núñez Díaz-Montes

🐛 Mihai Ionut
Mihai Ionut

🐛 Mikhail Kuchma
Mikhail Kuchma

🐛 Mirek Hankus
Mirek Hankus

🐛 - Mitch Spano
Mitch Spano

🐛 + Mitch Spano
Mitch Spano

🐛 Mladjan Gadzic
Mladjan Gadzic

🐛 MrAngry52
MrAngry52

🐛 Muminur Choudhury
Muminur Choudhury

🐛 Mykhailo Palahuta
Mykhailo Palahuta

💻 🐛 Nagendra Kumar Singh
Nagendra Kumar Singh

🐛 Nahuel Barrios
Nahuel Barrios

🐛 - Nakul Sharma
Nakul Sharma

🐛 + Nakul Sharma
Nakul Sharma

🐛 Nathan Braun
Nathan Braun

🐛 Nathan Reynolds
Nathan Reynolds

🐛 Nathan Reynolds
Nathan Reynolds

🐛 Nathanaël
Nathanaël

🐛 Naveen
Naveen

💻 Nazdravi
Nazdravi

🐛 - Neha-Dhonde
Neha-Dhonde

🐛 + Neha-Dhonde
Neha-Dhonde

🐛 Nicholas Doyle
Nicholas Doyle

🐛 Nick Butcher
Nick Butcher

🐛 Nico Gallinal
Nico Gallinal

🐛 Nicola Dal Maso
Nicola Dal Maso

🐛 Nicolas Filotto
Nicolas Filotto

💻 Nicolas Vervelle
Nicolas Vervelle

🐛 - Nicolas Vuillamy
Nicolas Vuillamy

📖 + Nicolas Vuillamy
Nicolas Vuillamy

📖 Nikita Chursin
Nikita Chursin

🐛 Niklas Baudy
Niklas Baudy

🐛 Nikolas Havrikov
Nikolas Havrikov

🐛 Nilesh Virkar
Nilesh Virkar

🐛 Nimit Patel
Nimit Patel

🐛 Niranjan Harpale
Niranjan Harpale

🐛 - Nirvik Patel
Nirvik Patel

💻 + Nirvik Patel
Nirvik Patel

💻 Noah Sussman
Noah Sussman

🐛 Noah0120
Noah0120

🐛 Noam Tamim
Noam Tamim

🐛 Noel Grandin
Noel Grandin

🐛 Olaf Haalstra
Olaf Haalstra

🐛 Oleg Andreych
Oleg Andreych

💻 🐛 - Oleg Pavlenko
Oleg Pavlenko

🐛 + Oleg Pavlenko
Oleg Pavlenko

🐛 Oleksii Dykov
Oleksii Dykov

💻 🐛 Oliver Eikemeier
Oliver Eikemeier

🐛 Oliver Siegmar
Oliver Siegmar

💵 Olivier Parent
Olivier Parent

💻 🐛 Ollie Abbey
Ollie Abbey

💻 🐛 Ondrej Kratochvil
Ondrej Kratochvil

🐛 - OverDrone
OverDrone

🐛 + OverDrone
OverDrone

🐛 Ozan Gulle
Ozan Gulle

💻 🐛 PUNEET JAIN
PUNEET JAIN

🐛 Parbati Bose
Parbati Bose

🐛 Paul Berg
Paul Berg

🐛 Paul Guyot
Paul Guyot

💻 Pavel Bludov
Pavel Bludov

🐛 - Pavel Mička
Pavel Mička

🐛 + Pavel Mička
Pavel Mička

🐛 Pedro Nuno Santos
Pedro Nuno Santos

🐛 Pedro Rijo
Pedro Rijo

🐛 Pelisse Romain
Pelisse Romain

💻 📖 🐛 Per Abich
Per Abich

💻 Pete Davids
Pete Davids

🐛 Peter Bruin
Peter Bruin

🐛 - Peter Chittum
Peter Chittum

💻 🐛 + Peter Chittum
Peter Chittum

💻 🐛 Peter Cudmore
Peter Cudmore

🐛 Peter Kasson
Peter Kasson

🐛 Peter Kofler
Peter Kofler

🐛 Peter Paul Bakker
Peter Paul Bakker

💻 Peter Rader
Peter Rader

🐛 Pham Hai Trung
Pham Hai Trung

🐛 - Philip Graf
Philip Graf

💻 🐛 + Philip Graf
Philip Graf

💻 🐛 Philip Hachey
Philip Hachey

🐛 Philippe Ozil
Philippe Ozil

🐛 Phinehas Artemix
Phinehas Artemix

🐛 Phokham Nonava
Phokham Nonava

🐛 Pim van der Loos
Pim van der Loos

💻 ⚠️ Piotr Szymański
Piotr Szymański

🐛 - Piotrek Żygieło
Piotrek Żygieło

💻 🐛 📖 + Piotrek Żygieło
Piotrek Żygieło

💻 🐛 📖 Pranay Jaiswal
Pranay Jaiswal

🐛 Prasad Kamath
Prasad Kamath

🐛 Prasanna
Prasanna

🐛 Presh-AR
Presh-AR

🐛 Puneet1726
Puneet1726

🐛 RBRi
RBRi

🐛 - Rafael Cortês
Rafael Cortês

🐛 + Rafael Cortês
Rafael Cortês

🐛 RaheemShaik999
RaheemShaik999

🐛 RajeshR
RajeshR

💻 🐛 Ramachandra Mohan
Ramachandra Mohan

🐛 Ramel0921
Ramel0921

🐛 Raquel Pau
Raquel Pau

🐛 Ravikiran Janardhana
Ravikiran Janardhana

🐛 - Reda Benhemmouche
Reda Benhemmouche

🐛 + Reda Benhemmouche
Reda Benhemmouche

🐛 Reinhard Schiedermeier
Reinhard Schiedermeier

🐛 Renato Oliveira
Renato Oliveira

💻 🐛 Rich DiCroce
Rich DiCroce

🐛 Richard Corfield
Richard Corfield

💻 Richard Corfield
Richard Corfield

🐛 💻 Riot R1cket
Riot R1cket

🐛 - Rishabh Jain
Rishabh Jain

🐛 + Rishabh Jain
Rishabh Jain

🐛 RishabhDeep Singh
RishabhDeep Singh

🐛 Rob Baillie
Rob Baillie

🐛 Robbie Martinus
Robbie Martinus

💻 🐛 Robert Henry
Robert Henry

🐛 Robert Mihaly
Robert Mihaly

🐛 Robert Painsi
Robert Painsi

🐛 - Robert Russell
Robert Russell

🐛 + Robert Russell
Robert Russell

🐛 Robert Sösemann
Robert Sösemann

💻 📖 📢 🐛 Robert Whitebit
Robert Whitebit

🐛 Robin Richtsfeld
Robin Richtsfeld

🐛 Robin Stocker
Robin Stocker

💻 🐛 Robin Wils
Robin Wils

🐛 RochusOest
RochusOest

🐛 - Rodolfo Noviski
Rodolfo Noviski

🐛 + Rodolfo Noviski
Rodolfo Noviski

🐛 Rodrigo Casara
Rodrigo Casara

🐛 Rodrigo Fernandes
Rodrigo Fernandes

🐛 Roman Salvador
Roman Salvador

💻 🐛 Ronald Blaschke
Ronald Blaschke

🐛 Róbert Papp
Róbert Papp

🐛 Saikat Sengupta
Saikat Sengupta

🐛 - Saksham Handu
Saksham Handu

🐛 + Saksham Handu
Saksham Handu

🐛 Saladoc
Saladoc

🐛 Salesforce Bob Lightning
Salesforce Bob Lightning

🐛 Sam Carlberg
Sam Carlberg

🐛 Sascha Riemer
Sascha Riemer

🐛 Sashko
Sashko

💻 Satoshi Kubo
Satoshi Kubo

🐛 - Scott Kennedy
Scott Kennedy

🐛 + Scott Kennedy
Scott Kennedy

🐛 Scott Wells
Scott Wells

🐛 💻 Scrates1
Scrates1

🐛 💻 Scrsloota
Scrsloota

💻 Sebastian Bögl
Sebastian Bögl

🐛 Sebastian Davids
Sebastian Davids

🐛 Sebastian Schuberth
Sebastian Schuberth

🐛 - Sebastian Schwarz
Sebastian Schwarz

🐛 + Sebastian Schwarz
Sebastian Schwarz

🐛 Seren
Seren

🐛 💻 Sergey Gorbaty
Sergey Gorbaty

🐛 Sergey Kozlov
Sergey Kozlov

🐛 Sergey Yanzin
Sergey Yanzin

💻 🐛 Seth Wilcox
Seth Wilcox

💻 Shai Bennathan
Shai Bennathan

🐛 💻 - Shubham
Shubham

💻 🐛 + Shubham
Shubham

💻 🐛 Simon Abykov
Simon Abykov

💻 🐛 Simon Xiao
Simon Xiao

🐛 Srinivasan Venkatachalam
Srinivasan Venkatachalam

🐛 Stanislav Gromov
Stanislav Gromov

🐛 Stanislav Myachenkov
Stanislav Myachenkov

💻 Stefan Birkner
Stefan Birkner

🐛 - Stefan Bohn
Stefan Bohn

🐛 + Stefan Bohn
Stefan Bohn

🐛 Stefan Endrullis
Stefan Endrullis

🐛 Stefan Klöss-Schuster
Stefan Klöss-Schuster

🐛 Stefan Wolf
Stefan Wolf

🐛 Stephan H. Wissel
Stephan H. Wissel

🐛 Stephen
Stephen

🐛 Stephen Carter
Stephen Carter

🐛 - Stephen Friedrich
Stephen Friedrich

🐛 + Stephen Friedrich
Stephen Friedrich

🐛 Steve Babula
Steve Babula

💻 Steven Stearns
Steven Stearns

🐛 💻 Stexxe
Stexxe

🐛 Stian Lågstad
Stian Lågstad

🐛 StuartClayton5
StuartClayton5

🐛 Supun Arunoda
Supun Arunoda

🐛 - Suren Abrahamyan
Suren Abrahamyan

🐛 + Suren Abrahamyan
Suren Abrahamyan

🐛 Suvashri
Suvashri

📖 SwatiBGupta1110
SwatiBGupta1110

🐛 SyedThoufich
SyedThoufich

🐛 Szymon Sasin
Szymon Sasin

🐛 T-chuangxin
T-chuangxin

🐛 TERAI Atsuhiro
TERAI Atsuhiro

🐛 - TIOBE Software
TIOBE Software

💻 🐛 + TIOBE Software
TIOBE Software

💻 🐛 Tarush Singh
Tarush Singh

💻 Taylor Smock
Taylor Smock

🐛 Techeira Damián
Techeira Damián

💻 🐛 Ted Husted
Ted Husted

🐛 TehBakker
TehBakker

🐛 The Gitter Badger
The Gitter Badger

🐛 - Theodoor
Theodoor

🐛 + Theodoor
Theodoor

🐛 Thiago Henrique Hüpner
Thiago Henrique Hüpner

🐛 Thibault Meyer
Thibault Meyer

🐛 Thomas Güttler
Thomas Güttler

🐛 Thomas Jones-Low
Thomas Jones-Low

🐛 Thomas Smith
Thomas Smith

💻 🐛 ThrawnCA
ThrawnCA

🐛 - Thu Vo
Thu Vo

🐛 + Thu Vo
Thu Vo

🐛 Thunderforge
Thunderforge

💻 🐛 Tim van der Lippe
Tim van der Lippe

🐛 Tobias Weimer
Tobias Weimer

💻 🐛 Tom Copeland
Tom Copeland

🐛 💻 📖 Tom Daly
Tom Daly

🐛 Tomas
Tomas

🐛 - Tomer Figenblat
Tomer Figenblat

🐛 + Tomer Figenblat
Tomer Figenblat

🐛 Tomi De Lucca
Tomi De Lucca

💻 🐛 Tony
Tony

📖 Torsten Kleiber
Torsten Kleiber

🐛 TrackerSB
TrackerSB

🐛 Tyson Stewart
Tyson Stewart

🐛 Ullrich Hafner
Ullrich Hafner

🐛 - Utku Cuhadaroglu
Utku Cuhadaroglu

💻 🐛 + Utku Cuhadaroglu
Utku Cuhadaroglu

💻 🐛 Valentin Brandl
Valentin Brandl

🐛 Valeria
Valeria

🐛 Valery Yatsynovich
Valery Yatsynovich

📖 Vasily Anisimov
Vasily Anisimov

🐛 Vedant Chokshi
Vedant Chokshi

🐛 Vibhor Goyal
Vibhor Goyal

🐛 - Vickenty Fesunov
Vickenty Fesunov

🐛 + Vickenty Fesunov
Vickenty Fesunov

🐛 Victor Noël
Victor Noël

🐛 Vincent Galloy
Vincent Galloy

💻 Vincent HUYNH
Vincent HUYNH

🐛 Vincent Maurin
Vincent Maurin

🐛 Vincent Privat
Vincent Privat

🐛 Vishhwas
Vishhwas

🐛 - Vishv_Android
Vishv_Android

🐛 + Vishv_Android
Vishv_Android

🐛 Vitaly
Vitaly

🐛 Vitaly Polonetsky
Vitaly Polonetsky

🐛 Vojtech Polivka
Vojtech Polivka

🐛 Vsevolod Zholobov
Vsevolod Zholobov

🐛 Vyom Yadav
Vyom Yadav

💻 Wang Shidong
Wang Shidong

🐛 - Waqas Ahmed
Waqas Ahmed

🐛 + Waqas Ahmed
Waqas Ahmed

🐛 Wayne J. Earl
Wayne J. Earl

🐛 Wchenghui
Wchenghui

🐛 Wener
Wener

💻 Will Winder
Will Winder

🐛 William Brockhus
William Brockhus

💻 🐛 Wilson Kurniawan
Wilson Kurniawan

🐛 - Wim Deblauwe
Wim Deblauwe

🐛 + Wim Deblauwe
Wim Deblauwe

🐛 Woongsik Choi
Woongsik Choi

🐛 XenoAmess
XenoAmess

💻 🐛 Yang
Yang

💻 YaroslavTER
YaroslavTER

🐛 Yasar Shaikh
Yasar Shaikh

💻 Young Chan
Young Chan

💻 🐛 - YuJin Kim
YuJin Kim

🐛 + YuJin Kim
YuJin Kim

🐛 Yuri Dolzhenko
Yuri Dolzhenko

🐛 Yurii Dubinka
Yurii Dubinka

🐛 Zoltan Farkas
Zoltan Farkas

🐛 Zustin
Zustin

🐛 aaronhurst-google
aaronhurst-google

🐛 💻 alexmodis
alexmodis

🐛 - andreoss
andreoss

🐛 + andreoss
andreoss

🐛 andrey81inmd
andrey81inmd

💻 🐛 anicoara
anicoara

🐛 arunprasathav
arunprasathav

🐛 asiercamara
asiercamara

🐛 astillich-igniti
astillich-igniti

💻 avesolovksyy
avesolovksyy

🐛 - avishvat
avishvat

🐛 + avishvat
avishvat

🐛 avivmu
avivmu

🐛 axelbarfod1
axelbarfod1

🐛 b-3-n
b-3-n

🐛 balbhadra9
balbhadra9

🐛 base23de
base23de

🐛 bergander
bergander

🐛 💻 - berkam
berkam

💻 🐛 + berkam
berkam

💻 🐛 breizh31
breizh31

🐛 caesarkim
caesarkim

🐛 carolyujing
carolyujing

🐛 cbfiddle
cbfiddle

🐛 cesares-basilico
cesares-basilico

🐛 chrite
chrite

🐛 - ciufudean
ciufudean

📖 + ciufudean
ciufudean

📖 cobratbq
cobratbq

🐛 coladict
coladict

🐛 cosmoJFH
cosmoJFH

🐛 cristalp
cristalp

🐛 crunsk
crunsk

🐛 cwholmes
cwholmes

🐛 - cyberjj999
cyberjj999

🐛 + cyberjj999
cyberjj999

🐛 cyw3
cyw3

🐛 📖 d1ss0nanz
d1ss0nanz

🐛 dague1
dague1

📖 dalizi007
dalizi007

💻 danbrycefairsailcom
danbrycefairsailcom

🐛 dariansanity
dariansanity

🐛 - darrenmiliband
darrenmiliband

🐛 + darrenmiliband
darrenmiliband

🐛 davidburstrom
davidburstrom

🐛 dbirkman-paloalto
dbirkman-paloalto

🐛 deepak-patra
deepak-patra

🐛 dependabot[bot]
dependabot[bot]

💻 🐛 dinesh150
dinesh150

🐛 diziaq
diziaq

🐛 - dreaminpast123
dreaminpast123

🐛 + dreaminpast123
dreaminpast123

🐛 duanyanan
duanyanan

🐛 dutt-sanjay
dutt-sanjay

🐛 duursma
duursma

💻 dylanleung
dylanleung

🐛 dzeigler
dzeigler

🐛 eant60
eant60

🐛 - ekkirala
ekkirala

🐛 + ekkirala
ekkirala

🐛 emersonmoura
emersonmoura

🐛 emouty
emouty

💻 eugenepugach
eugenepugach

🐛 fairy
fairy

🐛 filiprafalowicz
filiprafalowicz

💻 flxbl-io
flxbl-io

💵 - foxmason
foxmason

🐛 + foxmason
foxmason

🐛 frankegabor
frankegabor

🐛 frankl
frankl

🐛 freafrea
freafrea

🐛 fsapatin
fsapatin

🐛 gearsethenry
gearsethenry

🐛 gracia19
gracia19

🐛 - guo fei
guo fei

🐛 + guo fei
guo fei

🐛 gurmsc5
gurmsc5

🐛 gwilymatgearset
gwilymatgearset

💻 🐛 haigsn
haigsn

🐛 hemanshu070
hemanshu070

🐛 henrik242
henrik242

🐛 hongpuwu
hongpuwu

🐛 - hvbtup
hvbtup

💻 🐛 + hvbtup
hvbtup

💻 🐛 igniti GmbH
igniti GmbH

🐛 ilovezfs
ilovezfs

🐛 imax-erik
imax-erik

🐛 itaigilo
itaigilo

🐛 jakivey32
jakivey32

🐛 jbennett2091
jbennett2091

🐛 - jcamerin
jcamerin

🐛 + jcamerin
jcamerin

🐛 jkeener1
jkeener1

🐛 jmetertea
jmetertea

🐛 johnra2
johnra2

💻 johnzhao9
johnzhao9

🐛 josemanuelrolon
josemanuelrolon

💻 🐛 kabroxiko
kabroxiko

💻 🐛 - karthikaiyasamy
karthikaiyasamy

📖 + karthikaiyasamy
karthikaiyasamy

📖 karwer
karwer

🐛 kaulonline
kaulonline

🐛 kdaemonv
kdaemonv

🐛 kdebski85
kdebski85

🐛 💻 kenji21
kenji21

💻 🐛 kfranic
kfranic

🐛 - khalidkh
khalidkh

🐛 + khalidkh
khalidkh

🐛 koalalam
koalalam

🐛 krzyk
krzyk

🐛 lasselindqvist
lasselindqvist

🐛 lgemeinhardt
lgemeinhardt

🐛 lihuaib
lihuaib

🐛 liqingjun123
liqingjun123

🐛 - lonelyma1021
lonelyma1021

🐛 + lonelyma1021
lonelyma1021

🐛 lpeddy
lpeddy

🐛 lujiefsi
lujiefsi

💻 lukelukes
lukelukes

💻 lyriccoder
lyriccoder

🐛 marcelmore
marcelmore

🐛 matchbox
matchbox

🐛 - matthiaskraaz
matthiaskraaz

🐛 + matthiaskraaz
matthiaskraaz

🐛 meandonlyme
meandonlyme

🐛 mikesive
mikesive

🐛 milossesic
milossesic

🐛 mluckam
mluckam

💻 🐛 mohan-chinnappan-n
mohan-chinnappan-n

💻 mriddell95
mriddell95

🐛 - mrlzh
mrlzh

🐛 + mrlzh
mrlzh

🐛 msloan
msloan

🐛 mucharlaravalika
mucharlaravalika

🐛 mvenneman
mvenneman

🐛 nareshl119
nareshl119

🐛 nicolas-harraudeau-sonarsource
nicolas-harraudeau-sonarsource

🐛 noerremark
noerremark

🐛 - novsirion
novsirion

🐛 + novsirion
novsirion

🐛 nwcm
nwcm

📖 🐛 💻 oggboy
oggboy

🐛 oinume
oinume

🐛 orimarko
orimarko

💻 🐛 pablogomez2197
pablogomez2197

🐛 pacvz
pacvz

💻 - pallavi agarwal
pallavi agarwal

🐛 + pallavi agarwal
pallavi agarwal

🐛 parksungrin
parksungrin

🐛 patpatpat123
patpatpat123

🐛 patriksevallius
patriksevallius

🐛 pbrajesh1
pbrajesh1

🐛 phoenix384
phoenix384

🐛 piotrszymanski-sc
piotrszymanski-sc

💻 - plan3d
plan3d

🐛 + plan3d
plan3d

🐛 poojasix
poojasix

🐛 prabhushrikant
prabhushrikant

🐛 pujitha8783
pujitha8783

🐛 r-r-a-j
r-r-a-j

🐛 raghujayjunk
raghujayjunk

🐛 rajeshveera
rajeshveera

🐛 - rajeswarreddy88
rajeswarreddy88

🐛 + rajeswarreddy88
rajeswarreddy88

🐛 recdevs
recdevs

🐛 reudismam
reudismam

💻 🐛 rijkt
rijkt

🐛 rillig-tk
rillig-tk

🐛 rmohan20
rmohan20

💻 🐛 rnveach
rnveach

🐛 - rxmicro
rxmicro

🐛 + rxmicro
rxmicro

🐛 ryan-gustafson
ryan-gustafson

💻 🐛 sabi0
sabi0

🐛 scais
scais

🐛 schosin
schosin

🐛 screamingfrog
screamingfrog

💵 sebbASF
sebbASF

🐛 - sergeygorbaty
sergeygorbaty

💻 + sergeygorbaty
sergeygorbaty

💻 shilko2013
shilko2013

🐛 shiomiyan
shiomiyan

📖 simeonKondr
simeonKondr

🐛 snajberk
snajberk

🐛 sniperrifle2004
sniperrifle2004

🐛 snuyanzin
snuyanzin

🐛 💻 - soloturn
soloturn

🐛 + soloturn
soloturn

🐛 soyodream
soyodream

🐛 sratz
sratz

🐛 stonio
stonio

🐛 sturton
sturton

💻 🐛 sudharmohan
sudharmohan

🐛 suruchidawar
suruchidawar

🐛 - svenfinitiv
svenfinitiv

🐛 + svenfinitiv
svenfinitiv

🐛 szymanp23
szymanp23

🐛 💻 tashiscool
tashiscool

🐛 test-git-hook
test-git-hook

🐛 testation21
testation21

💻 🐛 thanosa
thanosa

🐛 tiandiyixian
tiandiyixian

🐛 - tobwoerk
tobwoerk

🐛 + tobwoerk
tobwoerk

🐛 tprouvot
tprouvot

🐛 💻 trentchilders
trentchilders

🐛 triandicAnt
triandicAnt

🐛 trishul14
trishul14

🐛 tsui
tsui

🐛 wangzitom12306
wangzitom12306

🐛 - winhkey
winhkey

🐛 + winhkey
winhkey

🐛 witherspore
witherspore

🐛 wjljack
wjljack

🐛 wuchiuwong
wuchiuwong

🐛 xingsong
xingsong

🐛 xioayuge
xioayuge

🐛 xnYi9wRezm
xnYi9wRezm

💻 🐛 - xuanuy
xuanuy

🐛 + xuanuy
xuanuy

🐛 xyf0921
xyf0921

🐛 yalechen-cyw3
yalechen-cyw3

🐛 yasuharu-sato
yasuharu-sato

🐛 zenglian
zenglian

🐛 zgrzyt93
zgrzyt93

💻 🐛 zh3ng
zh3ng

🐛 - zt_soft
zt_soft

🐛 + zt_soft
zt_soft

🐛 ztt79
ztt79

🐛 zzzzfeng
zzzzfeng

🐛 Árpád Magosányi
Árpád Magosányi

🐛 From a0d4b38b5349d27bd4762080131e0362d2fe26da Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 18 Oct 2024 16:16:54 +0200 Subject: [PATCH 24/52] [doc] Update release notes (#5245) --- docs/pages/release_notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 5c5329437e..088b0f9d06 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -55,6 +55,7 @@ The old rule names still work but are deprecated. * [#4965](https://github.com/pmd/pmd/pull/4965): Fix #4532: \[java] Rename JUnit rules with overly restrictive names - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) * [#5225](https://github.com/pmd/pmd/pull/5225): Fix #5067: \[java] CloseResource: False positive for FileSystems.getDefault() - [Lukas Gräf](https://github.com/lukasgraef) (@lukasgraef) * [#5241](https://github.com/pmd/pmd/pull/5241): Ignore javacc code in coverage report - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) +* [#5245](https://github.com/pmd/pmd/pull/5245): \[java] Improve UnitTestShouldUse{After,Before}Annotation rules to support JUnit5 and TestNG - [Andreas Dangel](https://github.com/adangel) (@adangel) * [#5258](https://github.com/pmd/pmd/pull/5258): Ignore generated antlr classes in coverage reports - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) * [#5264](https://github.com/pmd/pmd/pull/5264): Fix #5261: \[java] Fix NPE with empty pattern list - [Clément Fournier](https://github.com/oowekyala) (@oowekyala) * [#5269](https://github.com/pmd/pmd/pull/5269): Fix #5253: \[java] Support Boolean wrapper class for BooleanGetMethodName rule - [Aryant Tripathi](https://github.com/Aryant-Tripathi) (@Aryant-Tripathi) From 81429a46288a8a119988d5acbf94ffcf1819423e Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 18 Oct 2024 16:21:02 +0200 Subject: [PATCH 25/52] [doc] Update release notes (#5247) --- docs/pages/release_notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 5f7705b691..6c8174d241 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -53,6 +53,7 @@ The old rule names still work but are deprecated. * [#4965](https://github.com/pmd/pmd/pull/4965): Fix #4532: \[java] Rename JUnit rules with overly restrictive names - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) * [#5225](https://github.com/pmd/pmd/pull/5225): Fix #5067: \[java] CloseResource: False positive for FileSystems.getDefault() - [Lukas Gräf](https://github.com/lukasgraef) (@lukasgraef) * [#5241](https://github.com/pmd/pmd/pull/5241): Ignore javacc code in coverage report - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) +* [#5247](https://github.com/pmd/pmd/pull/5247): Fix #5030: \[java] SwitchDensity false positive with pattern matching - [Andreas Dangel](https://github.com/adangel) (@adangel) * [#5258](https://github.com/pmd/pmd/pull/5258): Ignore generated antlr classes in coverage reports - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) * [#5264](https://github.com/pmd/pmd/pull/5264): Fix #5261: \[java] Fix NPE with empty pattern list - [Clément Fournier](https://github.com/oowekyala) (@oowekyala) * [#5269](https://github.com/pmd/pmd/pull/5269): Fix #5253: \[java] Support Boolean wrapper class for BooleanGetMethodName rule - [Aryant Tripathi](https://github.com/Aryant-Tripathi) (@Aryant-Tripathi) From fd8fcd67d66a181e6362305bcbe19a19d1b793fd Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 18 Oct 2024 16:23:17 +0200 Subject: [PATCH 26/52] [doc] Update release notes (#5248) --- docs/pages/release_notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index c0c6fea785..85a758234c 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -52,6 +52,7 @@ The old rule names still work but are deprecated. * [#4965](https://github.com/pmd/pmd/pull/4965): Fix #4532: \[java] Rename JUnit rules with overly restrictive names - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) * [#5225](https://github.com/pmd/pmd/pull/5225): Fix #5067: \[java] CloseResource: False positive for FileSystems.getDefault() - [Lukas Gräf](https://github.com/lukasgraef) (@lukasgraef) * [#5241](https://github.com/pmd/pmd/pull/5241): Ignore javacc code in coverage report - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) +* [#5248](https://github.com/pmd/pmd/pull/5248): Fix #3362: \[java] ImplicitSwitchFallThrough should consider switch expressions - [Andreas Dangel](https://github.com/adangel) (@adangel) * [#5258](https://github.com/pmd/pmd/pull/5258): Ignore generated antlr classes in coverage reports - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) * [#5264](https://github.com/pmd/pmd/pull/5264): Fix #5261: \[java] Fix NPE with empty pattern list - [Clément Fournier](https://github.com/oowekyala) (@oowekyala) * [#5269](https://github.com/pmd/pmd/pull/5269): Fix #5253: \[java] Support Boolean wrapper class for BooleanGetMethodName rule - [Aryant Tripathi](https://github.com/Aryant-Tripathi) (@Aryant-Tripathi) From 665504decc34d037b674afe3fcf9ea13bc819484 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 18 Oct 2024 16:30:41 +0200 Subject: [PATCH 27/52] [doc] Update release notes (#5251) --- docs/pages/release_notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index f01329a652..217f0640ca 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -58,6 +58,7 @@ The old rule names still work but are deprecated. * [#4965](https://github.com/pmd/pmd/pull/4965): Fix #4532: \[java] Rename JUnit rules with overly restrictive names - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) * [#5225](https://github.com/pmd/pmd/pull/5225): Fix #5067: \[java] CloseResource: False positive for FileSystems.getDefault() - [Lukas Gräf](https://github.com/lukasgraef) (@lukasgraef) * [#5241](https://github.com/pmd/pmd/pull/5241): Ignore javacc code in coverage report - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) +* [#5251](https://github.com/pmd/pmd/pull/5251): Fix #5249 and #5250: \[java] TooFewBranchesForSwitch ignore pattern matching and support switch expressions - [Andreas Dangel](https://github.com/adangel) (@adangel) * [#5258](https://github.com/pmd/pmd/pull/5258): Ignore generated antlr classes in coverage reports - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) * [#5264](https://github.com/pmd/pmd/pull/5264): Fix #5261: \[java] Fix NPE with empty pattern list - [Clément Fournier](https://github.com/oowekyala) (@oowekyala) * [#5269](https://github.com/pmd/pmd/pull/5269): Fix #5253: \[java] Support Boolean wrapper class for BooleanGetMethodName rule - [Aryant Tripathi](https://github.com/Aryant-Tripathi) (@Aryant-Tripathi) From 5df7dccfb637ed83ba170723b7931adfe35c4752 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 18 Oct 2024 16:40:27 +0200 Subject: [PATCH 28/52] [doc] Update release notes (#5255) --- docs/pages/release_notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index c33b211b8a..3290251f55 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -53,6 +53,7 @@ The old rule names still work but are deprecated. * [#4965](https://github.com/pmd/pmd/pull/4965): Fix #4532: \[java] Rename JUnit rules with overly restrictive names - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) * [#5225](https://github.com/pmd/pmd/pull/5225): Fix #5067: \[java] CloseResource: False positive for FileSystems.getDefault() - [Lukas Gräf](https://github.com/lukasgraef) (@lukasgraef) * [#5241](https://github.com/pmd/pmd/pull/5241): Ignore javacc code in coverage report - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) +* [#5255](https://github.com/pmd/pmd/pull/5255): \[java] Rename rule DefaultLabelNotLastInSwitch - [Andreas Dangel](https://github.com/adangel) (@adangel) * [#5258](https://github.com/pmd/pmd/pull/5258): Ignore generated antlr classes in coverage reports - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) * [#5264](https://github.com/pmd/pmd/pull/5264): Fix #5261: \[java] Fix NPE with empty pattern list - [Clément Fournier](https://github.com/oowekyala) (@oowekyala) * [#5269](https://github.com/pmd/pmd/pull/5269): Fix #5253: \[java] Support Boolean wrapper class for BooleanGetMethodName rule - [Aryant Tripathi](https://github.com/Aryant-Tripathi) (@Aryant-Tripathi) From 6d55f6f05314b5dbca9497176ce7ceedde24433f Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 18 Oct 2024 17:42:44 +0200 Subject: [PATCH 29/52] [java] UselessOperationOnImmutable: consider java.time.* types Fixes #5244 --- docs/pages/release_notes.md | 1 + .../UselessOperationOnImmutableRule.java | 7 ++ .../resources/category/java/errorprone.xml | 7 +- .../xml/UselessOperationOnImmutable.xml | 108 ++++++++++++++++++ 4 files changed, 120 insertions(+), 3 deletions(-) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 8b0a13de9b..76d317b4a9 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -36,6 +36,7 @@ The old rule names still work but are deprecated. * [#5253](https://github.com/pmd/pmd/issues/5253): \[java] BooleanGetMethodName: False-negatives with `Boolean` wrapper * java-errorprone * [#5067](https://github.com/pmd/pmd/issues/5067): \[java] CloseResource: False positive for FileSystems.getDefault() + * [#5244](https://github.com/pmd/pmd/issues/5244): \[java] UselessOperationOnImmutable should detect java.time types ### 🚨 API Changes * java-bestpractices diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/UselessOperationOnImmutableRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/UselessOperationOnImmutableRule.java index ac59da9d76..c326446c5e 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/UselessOperationOnImmutableRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/UselessOperationOnImmutableRule.java @@ -6,6 +6,9 @@ package net.sourceforge.pmd.lang.java.rule.errorprone; import java.math.BigDecimal; import java.math.BigInteger; +import java.time.Duration; +import java.time.Period; +import java.time.temporal.Temporal; import net.sourceforge.pmd.lang.java.ast.ASTExpression; import net.sourceforge.pmd.lang.java.ast.ASTExpressionStatement; @@ -38,6 +41,10 @@ public class UselessOperationOnImmutableRule extends AbstractJavaRulechainRule { } else if (TypeTestUtil.isA(BigDecimal.class, qualifier) || TypeTestUtil.isA(BigInteger.class, qualifier)) { asCtx(data).addViolation(node); + } else if (TypeTestUtil.isA(Temporal.class, qualifier) + || TypeTestUtil.isA(Duration.class, qualifier) + || TypeTestUtil.isA(Period.class, qualifier)) { + asCtx(data).addViolation(node); } } return null; diff --git a/pmd-java/src/main/resources/category/java/errorprone.xml b/pmd-java/src/main/resources/category/java/errorprone.xml index 1f9ed37765..8aa8961a6f 100644 --- a/pmd-java/src/main/resources/category/java/errorprone.xml +++ b/pmd-java/src/main/resources/category/java/errorprone.xml @@ -3127,12 +3127,13 @@ public boolean test(String s) { -An operation on an Immutable object (String, BigDecimal or BigInteger) won't change the object itself -since the result of the operation is a new object. Therefore, ignoring the operation result is an error. +An operation on an Immutable object (`String`, `BigDecimal`, `BigInteger` or any type from `java.time.*`) +won't change the object itself since the result of the operation is a new object. +Therefore, ignoring the operation result is an error. 3 diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/UselessOperationOnImmutable.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/UselessOperationOnImmutable.xml index 111295638e..b311af77f0 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/UselessOperationOnImmutable.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/UselessOperationOnImmutable.xml @@ -210,6 +210,114 @@ public class TestCase { String.valueOf(0).trim(); } } +]]> + + + + [java] UselessOperationOnImmutable should detect java.time types #5244 + 44 + 7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,61,66,71,76 + + + + + [java] UselessOperationOnImmutable should detect java.time types #5244 - Duration, Period + 2 + 5,10 + From c47f5a60624409792fb1afd6328b50fc0db10afd Mon Sep 17 00:00:00 2001 From: Jakub Dupak Date: Fri, 24 May 2024 11:39:08 +0200 Subject: [PATCH 30/52] [cpd] Add ignore literals and identifiers capability to C++ --- docs/pages/pmd/userdocs/cpd/cpd.md | 4 +- .../pmd/lang/cpp/CppLanguageModule.java | 2 + .../pmd/lang/cpp/cpd/CppCpdLexer.java | 26 +++- .../pmd/lang/cpp/cpd/CppCpdLexerTest.java | 33 ++++- .../lang/cpp/cpd/testdata/ignoreIdents.cpp | 6 + .../lang/cpp/cpd/testdata/ignoreIdents.txt | 35 +++++ .../lang/cpp/cpd/testdata/ignoreLiterals.cpp | 43 ++++++ .../lang/cpp/cpd/testdata/ignoreLiterals.txt | 135 ++++++++++++++++++ 8 files changed, 274 insertions(+), 10 deletions(-) create mode 100644 pmd-cpp/src/test/resources/net/sourceforge/pmd/lang/cpp/cpd/testdata/ignoreIdents.cpp create mode 100644 pmd-cpp/src/test/resources/net/sourceforge/pmd/lang/cpp/cpd/testdata/ignoreIdents.txt create mode 100644 pmd-cpp/src/test/resources/net/sourceforge/pmd/lang/cpp/cpd/testdata/ignoreLiterals.cpp create mode 100644 pmd-cpp/src/test/resources/net/sourceforge/pmd/lang/cpp/cpd/testdata/ignoreLiterals.txt diff --git a/docs/pages/pmd/userdocs/cpd/cpd.md b/docs/pages/pmd/userdocs/cpd/cpd.md index 1bf2954c18..0580732bb4 100644 --- a/docs/pages/pmd/userdocs/cpd/cpd.md +++ b/docs/pages/pmd/userdocs/cpd/cpd.md @@ -163,7 +163,7 @@ exactly identical. {% include custom/cli_option_row.html options="--ignore-literals" description="Ignore literal values such as numbers and strings when comparing text. By default, literals are not ignored." - languages="Java" + languages="Java, C++" %} {% include custom/cli_option_row.html options="--ignore-literal-sequences" description="Ignore sequences of literals such as list initializers. @@ -173,7 +173,7 @@ exactly identical. {% include custom/cli_option_row.html options="--ignore-identifiers" description="Ignore names of classes, methods, variables, constants, etc. when comparing text. By default, identifier names are not ignored." - languages="Java" + languages="Java, C++" %} {% include custom/cli_option_row.html options="--ignore-annotations" description="Ignore language annotations (Java) or attributes (C#) when comparing text. diff --git a/pmd-cpp/src/main/java/net/sourceforge/pmd/lang/cpp/CppLanguageModule.java b/pmd-cpp/src/main/java/net/sourceforge/pmd/lang/cpp/CppLanguageModule.java index 520fc7327c..5312f8abaf 100644 --- a/pmd-cpp/src/main/java/net/sourceforge/pmd/lang/cpp/CppLanguageModule.java +++ b/pmd-cpp/src/main/java/net/sourceforge/pmd/lang/cpp/CppLanguageModule.java @@ -47,6 +47,8 @@ public class CppLanguageModule extends CpdOnlyLanguageModuleBase { LanguagePropertyBundle bundle = super.newPropertyBundle(); bundle.definePropertyDescriptor(CpdLanguageProperties.CPD_IGNORE_LITERAL_SEQUENCES); bundle.definePropertyDescriptor(CpdLanguageProperties.CPD_IGNORE_LITERAL_AND_IDENTIFIER_SEQUENCES); + bundle.definePropertyDescriptor(CpdLanguageProperties.CPD_ANONYMIZE_IDENTIFIERS); + bundle.definePropertyDescriptor(CpdLanguageProperties.CPD_ANONYMIZE_LITERALS); bundle.definePropertyDescriptor(CPD_SKIP_BLOCKS); return bundle; } diff --git a/pmd-cpp/src/main/java/net/sourceforge/pmd/lang/cpp/cpd/CppCpdLexer.java b/pmd-cpp/src/main/java/net/sourceforge/pmd/lang/cpp/cpd/CppCpdLexer.java index 5d0e423a51..69287747ba 100644 --- a/pmd-cpp/src/main/java/net/sourceforge/pmd/lang/cpp/cpd/CppCpdLexer.java +++ b/pmd-cpp/src/main/java/net/sourceforge/pmd/lang/cpp/cpd/CppCpdLexer.java @@ -9,8 +9,9 @@ import java.util.regex.Pattern; import org.apache.commons.lang3.StringUtils; import net.sourceforge.pmd.cpd.CpdLanguageProperties; -import net.sourceforge.pmd.cpd.impl.CpdLexerBase; +import net.sourceforge.pmd.cpd.TokenFactory; import net.sourceforge.pmd.cpd.impl.JavaCCTokenFilter; +import net.sourceforge.pmd.cpd.impl.JavaccCpdLexer; import net.sourceforge.pmd.lang.LanguagePropertyBundle; import net.sourceforge.pmd.lang.TokenManager; import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream; @@ -26,17 +27,21 @@ import net.sourceforge.pmd.lang.document.TextDocument; * *

Note: This class has been called CPPTokenizer in PMD 6

. */ -public class CppCpdLexer extends CpdLexerBase { +public class CppCpdLexer extends JavaccCpdLexer { private boolean skipBlocks; private Pattern skipBlocksStart; private Pattern skipBlocksEnd; private final boolean ignoreIdentifierAndLiteralSeqences; private final boolean ignoreLiteralSequences; + private final boolean ignoreLiterals; + private final boolean ignoreIdentifiers; public CppCpdLexer(LanguagePropertyBundle cppProperties) { ignoreLiteralSequences = cppProperties.getProperty(CpdLanguageProperties.CPD_IGNORE_LITERAL_SEQUENCES); ignoreIdentifierAndLiteralSeqences = cppProperties.getProperty(CpdLanguageProperties.CPD_IGNORE_LITERAL_AND_IDENTIFIER_SEQUENCES); + ignoreLiterals = cppProperties.getProperty(CpdLanguageProperties.CPD_ANONYMIZE_LITERALS); + ignoreIdentifiers = cppProperties.getProperty(CpdLanguageProperties.CPD_ANONYMIZE_IDENTIFIERS); String skipBlocksPattern = cppProperties.getProperty(CppLanguageModule.CPD_SKIP_BLOCKS); if (StringUtils.isNotBlank(skipBlocksPattern)) { skipBlocks = true; @@ -73,6 +78,23 @@ public class CppCpdLexer extends CpdLexerBase { return new CppTokenFilter(tokenManager, ignoreLiteralSequences, ignoreIdentifierAndLiteralSeqences); } + @Override + protected void processToken(TokenFactory tokenEntries, JavaccToken currentToken) { + int kind = currentToken.getKind(); + String image = currentToken.getImage(); + + boolean isLiteral = kind == CppTokenKinds.STRING || kind == CppTokenKinds.RSTRING || kind == CppTokenKinds.CHARACTER || kind == CppTokenKinds.DECIMAL_INT_LITERAL || kind == CppTokenKinds.HEXADECIMAL_INT_LITERAL || kind == CppTokenKinds.OCTAL_INT_LITERAL || kind == CppTokenKinds.FLOAT_LITERAL || kind == CppTokenKinds.BINARY_INT_LITERAL || kind == CppTokenKinds.ZERO; + if (ignoreLiterals && isLiteral) { + image = CppTokenKinds.describe(kind); + } + + if (ignoreIdentifiers && (kind == CppTokenKinds.ID)) { + image = CppTokenKinds.describe(kind); + } + + tokenEntries.recordToken(image, currentToken.getReportLocation()); + } + private static class CppTokenFilter extends JavaCCTokenFilter { private final boolean ignoreLiteralSequences; diff --git a/pmd-cpp/src/test/java/net/sourceforge/pmd/lang/cpp/cpd/CppCpdLexerTest.java b/pmd-cpp/src/test/java/net/sourceforge/pmd/lang/cpp/cpd/CppCpdLexerTest.java index 805bb9a86d..90bfe90a32 100644 --- a/pmd-cpp/src/test/java/net/sourceforge/pmd/lang/cpp/cpd/CppCpdLexerTest.java +++ b/pmd-cpp/src/test/java/net/sourceforge/pmd/lang/cpp/cpd/CppCpdLexerTest.java @@ -59,6 +59,16 @@ class CppCpdLexerTest extends CpdTextComparisonTest { doTest("specialComments"); } + @Test + void testIgnoreLiterals() { + doTest("ignoreLiterals", "", ignoreLiterals()); + } + + @Test + void testIgnoreIdents() { + doTest("ignoreIdents", "", ignoreIdents()); + } + @Test void testMultiLineMacros() { doTest("multilineMacros"); @@ -142,7 +152,7 @@ class CppCpdLexerTest extends CpdTextComparisonTest { } private static LanguagePropertyConfig skipBlocks(String skipPattern) { - return properties(true, skipPattern, false, false); + return properties(true, skipPattern, false, false, false, false); } private static LanguagePropertyConfig skipBlocks() { @@ -150,22 +160,31 @@ class CppCpdLexerTest extends CpdTextComparisonTest { } private static LanguagePropertyConfig dontSkipBlocks() { - return properties(false, null, false, false); + return properties(false, null, false, false, false, false); } private static LanguagePropertyConfig skipLiteralSequences() { - return properties(false, null, true, false); + return properties(false, null, true, false, false, false); } private static LanguagePropertyConfig skipIdentifierAndLiteralsSequences() { - return properties(false, null, true, true); + return properties(false, null, true, true, false, false); } private static LanguagePropertyConfig skipIdentifierSequences() { - return properties(false, null, false, true); + return properties(false, null, false, true, false, false); } - private static LanguagePropertyConfig properties(boolean skipBlocks, String skipPattern, boolean skipLiteralSequences, boolean skipSequences) { + private static LanguagePropertyConfig ignoreIdents() { + return properties(false, null, false, false, false, true); + } + + private static LanguagePropertyConfig ignoreLiterals() { + return properties(false, null, false, false, true, false); + } + + + private static LanguagePropertyConfig properties(boolean skipBlocks, String skipPattern, boolean skipLiteralSequences, boolean skipSequences, boolean ignoreLiterals, boolean ignoreIdents) { return properties -> { if (!skipBlocks) { properties.setProperty(CppLanguageModule.CPD_SKIP_BLOCKS, ""); @@ -174,6 +193,8 @@ class CppCpdLexerTest extends CpdTextComparisonTest { } properties.setProperty(CpdLanguageProperties.CPD_IGNORE_LITERAL_SEQUENCES, skipLiteralSequences); properties.setProperty(CpdLanguageProperties.CPD_IGNORE_LITERAL_AND_IDENTIFIER_SEQUENCES, skipSequences); + properties.setProperty(CpdLanguageProperties.CPD_ANONYMIZE_LITERALS, ignoreLiterals); + properties.setProperty(CpdLanguageProperties.CPD_ANONYMIZE_IDENTIFIERS, ignoreIdents); }; } } diff --git a/pmd-cpp/src/test/resources/net/sourceforge/pmd/lang/cpp/cpd/testdata/ignoreIdents.cpp b/pmd-cpp/src/test/resources/net/sourceforge/pmd/lang/cpp/cpd/testdata/ignoreIdents.cpp new file mode 100644 index 0000000000..91473e3e67 --- /dev/null +++ b/pmd-cpp/src/test/resources/net/sourceforge/pmd/lang/cpp/cpd/testdata/ignoreIdents.cpp @@ -0,0 +1,6 @@ +class Test { + void f(int a, float b) { + auto c = a + b; + int d = 6; + } +} \ No newline at end of file diff --git a/pmd-cpp/src/test/resources/net/sourceforge/pmd/lang/cpp/cpd/testdata/ignoreIdents.txt b/pmd-cpp/src/test/resources/net/sourceforge/pmd/lang/cpp/cpd/testdata/ignoreIdents.txt new file mode 100644 index 0000000000..b564fde247 --- /dev/null +++ b/pmd-cpp/src/test/resources/net/sourceforge/pmd/lang/cpp/cpd/testdata/ignoreIdents.txt @@ -0,0 +1,35 @@ + [Image] or [Truncated image[ Bcol Ecol +L1 + [class] 1 6 + [] 7 11 + [{] 12 13 +L2 + [void] 2 6 + [] 7 8 + [(] 8 9 + [int] 9 12 + [] 13 14 + [,] 14 15 + [float] 16 21 + [] 22 23 + [)] 23 24 + [{] 25 26 +L3 + [auto] 3 7 + [] 8 9 + [=] 10 11 + [] 12 13 + [+] 14 15 + [] 16 17 + [;] 17 18 +L4 + [int] 3 6 + [] 7 8 + [=] 9 10 + [6] 11 12 + [;] 12 13 +L5 + [}] 2 3 +L6 + [}] 1 2 +EOF diff --git a/pmd-cpp/src/test/resources/net/sourceforge/pmd/lang/cpp/cpd/testdata/ignoreLiterals.cpp b/pmd-cpp/src/test/resources/net/sourceforge/pmd/lang/cpp/cpd/testdata/ignoreLiterals.cpp new file mode 100644 index 0000000000..cbae7336ba --- /dev/null +++ b/pmd-cpp/src/test/resources/net/sourceforge/pmd/lang/cpp/cpd/testdata/ignoreLiterals.cpp @@ -0,0 +1,43 @@ + void main() { + char x = L'a'; // wide chars + x = '\0x05'; // hex + // x = L''; // empty character is an error + + print("\ oMedia"); // whitespace escape + + + // char prefixes + char16_t c = u'\u00F6'; + wchar_t b = L'\xFFEF'; + char a = '\x30'; + char32_t d = U'\U0010FFFF'; + + // string prefixes + char A[] = "Hello\x0A"; + wchar_t B[] = L"Hell\xF6\x0A"; + char16_t C[] = u"Hell\u00F6"; + char32_t D[] = U"Hell\U000000F6\U0010FFFF"; + auto E[] = u8"\u00F6\U0010FFFF"; + + + + char* rawString = R"( + [Sinks.1] + Destination=Console + AutoFlush=true + Format="[%TimeStamp%] %ThreadId% %QueryIdHigh% %QueryIdLow% %LoggerFile%:%Line% (%Severity%) - %Message%" + Filter="%Severity% >= WRN" + )"; + + + + // digit separators + auto integer_literal = 1'000''000; + auto floating_point_literal = 0.000'015'3; + auto hex_literal = 0x0F00'abcd'6f3d; + auto silly_example = 1'0'0'000'00; + + // boolean literals + int b1 = 0B001101; // C++ 14 binary literal + int b2 = 0b000001; // C++ 14 binary literal +} \ No newline at end of file diff --git a/pmd-cpp/src/test/resources/net/sourceforge/pmd/lang/cpp/cpd/testdata/ignoreLiterals.txt b/pmd-cpp/src/test/resources/net/sourceforge/pmd/lang/cpp/cpd/testdata/ignoreLiterals.txt new file mode 100644 index 0000000000..ef31240e44 --- /dev/null +++ b/pmd-cpp/src/test/resources/net/sourceforge/pmd/lang/cpp/cpd/testdata/ignoreLiterals.txt @@ -0,0 +1,135 @@ + [Image] or [Truncated image[ Bcol Ecol +L1 + [void] 2 6 + [main] 7 11 + [(] 11 12 + [)] 12 13 + [{] 14 15 +L2 + [char] 5 9 + [x] 10 11 + [=] 12 13 + [] 14 18 + [;] 18 19 +L3 + [x] 5 6 + [=] 7 8 + [] 9 16 + [;] 16 17 +L6 + [print] 5 10 + [(] 10 11 + [] 11 24 + [)] 24 25 + [;] 25 26 +L10 + [char16_t] 5 13 + [c] 14 15 + [=] 16 17 + [] 18 27 + [;] 27 28 +L11 + [wchar_t] 5 12 + [b] 13 14 + [=] 15 16 + [] 17 26 + [;] 26 27 +L12 + [char] 5 9 + [a] 10 11 + [=] 12 13 + [] 15 21 + [;] 21 22 +L13 + [char32_t] 5 13 + [d] 14 15 + [=] 16 17 + [] 18 31 + [;] 31 32 +L16 + [char] 5 9 + [A] 10 11 + [\[] 11 12 + [\]] 12 13 + [=] 14 15 + [] 16 27 + [;] 27 28 +L17 + [wchar_t] 5 12 + [B] 13 14 + [\[] 14 15 + [\]] 15 16 + [=] 17 18 + [] 19 34 + [;] 34 35 +L18 + [char16_t] 5 13 + [C] 14 15 + [\[] 15 16 + [\]] 16 17 + [=] 18 19 + [] 20 33 + [;] 33 34 +L19 + [char32_t] 5 13 + [D] 14 15 + [\[] 15 16 + [\]] 16 17 + [=] 18 19 + [] 20 47 + [;] 47 48 +L20 + [auto] 5 9 + [E] 10 11 + [\[] 11 12 + [\]] 12 13 + [=] 14 15 + [] 16 36 + [;] 36 37 +L24 + [char] 5 9 + [*] 9 10 + [rawString] 11 20 + [=] 21 22 + [] 23 7 +L30 + [;] 7 8 +L35 + [auto] 5 9 + [integer_literal] 10 25 + [=] 26 27 + [] 28 38 + [;] 38 39 +L36 + [auto] 5 9 + [floating_point_literal] 10 32 + [=] 33 34 + [] 35 46 + [;] 46 47 +L37 + [auto] 5 9 + [hex_literal] 10 21 + [=] 22 23 + [] 24 40 + [;] 40 41 +L38 + [auto] 5 9 + [silly_example] 10 23 + [=] 24 25 + [] 26 38 + [;] 38 39 +L41 + [int] 5 8 + [b1] 9 11 + [=] 12 13 + [] 14 22 + [;] 22 23 +L42 + [int] 5 8 + [b2] 9 11 + [=] 12 13 + [] 14 22 + [;] 22 23 +L43 + [}] 1 2 +EOF From 7ad4e0f0fc7a9897cf043012e3a1e8392d9a8a70 Mon Sep 17 00:00:00 2001 From: Jakub Dupak Date: Fri, 24 May 2024 11:48:03 +0200 Subject: [PATCH 31/52] Add @jdupak as a contributor --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 8d11a3745a..6d612e8df8 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -7846,6 +7846,15 @@ "contributions": [ "code" ] + }, + { + "login": "jdupak", + "name": "Jakub Dupak", + "avatar_url": "https://avatars.githubusercontent.com/u/22683640?v=4", + "profile": "https://github.com/jdupak", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 7, From 1517a18956e1b5fcac67279b33648c1bed690051 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 22 Oct 2024 20:23:50 +0200 Subject: [PATCH 32/52] Bump org.scala-lang:scala-reflect from 2.13.13 to 2.13.15 (#5281) Bumps [org.scala-lang:scala-reflect](https://github.com/scala/scala) from 2.13.13 to 2.13.15. - [Release notes](https://github.com/scala/scala/releases) - [Commits](https://github.com/scala/scala/compare/v2.13.13...v2.13.15) --- updated-dependencies: - dependency-name: org.scala-lang:scala-reflect dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 87bf5c3641..de14b5c3ae 100644 --- a/pom.xml +++ b/pom.xml @@ -910,7 +910,7 @@ org.scala-lang scala-reflect - 2.13.13 + 2.13.15 org.scala-lang From 09b0864eff98404d38a82a6888dd52ea1b391c22 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Tue, 22 Oct 2024 20:50:10 +0200 Subject: [PATCH 33/52] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Clément Fournier --- pmd-java/src/main/resources/category/java/errorprone.xml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pmd-java/src/main/resources/category/java/errorprone.xml b/pmd-java/src/main/resources/category/java/errorprone.xml index 8aa8961a6f..2d7cacb281 100644 --- a/pmd-java/src/main/resources/category/java/errorprone.xml +++ b/pmd-java/src/main/resources/category/java/errorprone.xml @@ -3127,13 +3127,14 @@ public boolean test(String s) { -An operation on an Immutable object (`String`, `BigDecimal`, `BigInteger` or any type from `java.time.*`) -won't change the object itself since the result of the operation is a new object. -Therefore, ignoring the operation result is an error. +An operation on an immutable object will not change the object itself since the result of the operation is a new object. +Therefore, ignoring the result of such an operation is likely a mistake. The operation can probably be removed. + +This rule recognizes the types `String`, `BigDecimal`, `BigInteger` or any type from `java.time.*` as immutable. 3 From c4b8f18a362f449a91888e6f9f638a0055ecbe84 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Tue, 22 Oct 2024 20:58:37 +0200 Subject: [PATCH 34/52] [doc] Update release notes (#5252) --- docs/pages/release_notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 5e51e607cb..e3abda244a 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -53,6 +53,7 @@ The old rule names still work but are deprecated. * [#4965](https://github.com/pmd/pmd/pull/4965): Fix #4532: \[java] Rename JUnit rules with overly restrictive names - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) * [#5225](https://github.com/pmd/pmd/pull/5225): Fix #5067: \[java] CloseResource: False positive for FileSystems.getDefault() - [Lukas Gräf](https://github.com/lukasgraef) (@lukasgraef) * [#5241](https://github.com/pmd/pmd/pull/5241): Ignore javacc code in coverage report - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) +* [#5252](https://github.com/pmd/pmd/pull/5252): Fix #4813: \[java] SwitchStmtsShouldHaveDefault false positive with pattern matching - [Andreas Dangel](https://github.com/adangel) (@adangel) * [#5258](https://github.com/pmd/pmd/pull/5258): Ignore generated antlr classes in coverage reports - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) * [#5264](https://github.com/pmd/pmd/pull/5264): Fix #5261: \[java] Fix NPE with empty pattern list - [Clément Fournier](https://github.com/oowekyala) (@oowekyala) * [#5269](https://github.com/pmd/pmd/pull/5269): Fix #5253: \[java] Support Boolean wrapper class for BooleanGetMethodName rule - [Aryant Tripathi](https://github.com/Aryant-Tripathi) (@Aryant-Tripathi) From 49f2c15b8352f963ce35c8eea61dc2d0147eaf79 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Tue, 22 Oct 2024 21:01:42 +0200 Subject: [PATCH 35/52] [doc] Update release notes (#5273) --- docs/pages/release_notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 48d330d2ac..e511592e8c 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -56,6 +56,7 @@ The old rule names still work but are deprecated. * [#5258](https://github.com/pmd/pmd/pull/5258): Ignore generated antlr classes in coverage reports - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) * [#5264](https://github.com/pmd/pmd/pull/5264): Fix #5261: \[java] Fix NPE with empty pattern list - [Clément Fournier](https://github.com/oowekyala) (@oowekyala) * [#5269](https://github.com/pmd/pmd/pull/5269): Fix #5253: \[java] Support Boolean wrapper class for BooleanGetMethodName rule - [Aryant Tripathi](https://github.com/Aryant-Tripathi) (@Aryant-Tripathi) +* [#5273](https://github.com/pmd/pmd/pull/5273): Fix #5270: \[apex] AvoidNonRestrictiveQueries: Fix regex for detecting LIMIT clause - [Andreas Dangel](https://github.com/adangel) (@adangel) * [#5275](https://github.com/pmd/pmd/pull/5275): Use plugin-classpath to simplify javacc-wrapper.xml - [Andreas Dangel](https://github.com/adangel) (@adangel) * [#5278](https://github.com/pmd/pmd/pull/5278): \[java] CouplingBetweenObjects: improve violation message - [Andreas Dangel](https://github.com/adangel) (@adangel) From 63675eaa18413b8ae44233fbc83988c8edade92f Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Tue, 22 Oct 2024 21:03:03 +0200 Subject: [PATCH 36/52] [doc] Update release notes (#5279) --- docs/pages/release_notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 76d317b4a9..cacf781aff 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -57,6 +57,7 @@ The old rule names still work but are deprecated. * [#5269](https://github.com/pmd/pmd/pull/5269): Fix #5253: \[java] Support Boolean wrapper class for BooleanGetMethodName rule - [Aryant Tripathi](https://github.com/Aryant-Tripathi) (@Aryant-Tripathi) * [#5275](https://github.com/pmd/pmd/pull/5275): Use plugin-classpath to simplify javacc-wrapper.xml - [Andreas Dangel](https://github.com/adangel) (@adangel) * [#5278](https://github.com/pmd/pmd/pull/5278): \[java] CouplingBetweenObjects: improve violation message - [Andreas Dangel](https://github.com/adangel) (@adangel) +* [#5279](https://github.com/pmd/pmd/pull/5279): Fix #5244: \[java] UselessOperationOnImmutable: consider java.time.* types - [Andreas Dangel](https://github.com/adangel) (@adangel) {% endtocmaker %} From a1802580336f7b9d1bce5d2156e9b7d248045c32 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 24 Oct 2024 10:17:51 +0200 Subject: [PATCH 37/52] [doc] Update release notes (#5040) --- docs/pages/release_notes.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 8b0a13de9b..f595d1a885 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -14,6 +14,13 @@ This is a {{ site.pmd.release_type }} release. ### 🚀 New and noteworthy +#### CPD can now ignore literals and identifiers in C++ code + +When searching for duplicated code in C++ differences in literals or identifiers can be +ignored now (like in Java). This can be enabled via the command line options `--ignore-literal` +and `--ignore-identifiers`. +See [PR #5040](https://github.com/pmd/pmd/pull/5040) for details. + ### 🌟 Rule Changes #### Renamed Rules @@ -49,6 +56,7 @@ The old rule names still work but are deprecated. ### ✨ Merged pull requests * [#4965](https://github.com/pmd/pmd/pull/4965): Fix #4532: \[java] Rename JUnit rules with overly restrictive names - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) +* [#5040](https://github.com/pmd/pmd/pull/5040): \[cpp] Ignore literals and ignore identifiers capability to C++ CPD - [Jakub Dupak](https://github.com/jdupak) (@jdupak) * [#5225](https://github.com/pmd/pmd/pull/5225): Fix #5067: \[java] CloseResource: False positive for FileSystems.getDefault() - [Lukas Gräf](https://github.com/lukasgraef) (@lukasgraef) * [#5241](https://github.com/pmd/pmd/pull/5241): Ignore javacc code in coverage report - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) * [#5258](https://github.com/pmd/pmd/pull/5258): Ignore generated antlr classes in coverage reports - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) From 6f5af6e5855a1eae51932cbb9b3417a3c3280c29 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 24 Oct 2024 11:22:47 +0200 Subject: [PATCH 38/52] [java] TooFewBranchesForSwitch: use new PatternLabel attribute --- pmd-java/src/main/resources/category/java/performance.xml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pmd-java/src/main/resources/category/java/performance.xml b/pmd-java/src/main/resources/category/java/performance.xml index 2a6d218354..a8e4c37142 100644 --- a/pmd-java/src/main/resources/category/java/performance.xml +++ b/pmd-java/src/main/resources/category/java/performance.xml @@ -628,9 +628,10 @@ Note: This rule was named TooFewBranchesForASwitchStatement before PMD 7.7.0. From 6c35c73919fe552afd8a624b074132558b96c391 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 24 Oct 2024 11:29:40 +0200 Subject: [PATCH 39/52] [java] SwitchStmtsShouldHaveDefault: use new PatternLabel attribute --- pmd-java/src/main/resources/category/java/bestpractices.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pmd-java/src/main/resources/category/java/bestpractices.xml b/pmd-java/src/main/resources/category/java/bestpractices.xml index 32fff7716f..b53d55d670 100644 --- a/pmd-java/src/main/resources/category/java/bestpractices.xml +++ b/pmd-java/src/main/resources/category/java/bestpractices.xml @@ -1177,9 +1177,11 @@ class SomeTestClass { From d9d6b57f2a32d9ff1f0cbf55e9960b4dad26e0c8 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 24 Oct 2024 12:38:45 +0200 Subject: [PATCH 40/52] [java] TooFewBranchesForSwitch: report empty switch This fixes a false negative --- .../main/resources/category/java/performance.xml | 2 +- .../performance/xml/TooFewBranchesForSwitch.xml | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pmd-java/src/main/resources/category/java/performance.xml b/pmd-java/src/main/resources/category/java/performance.xml index a8e4c37142..f2e7eef431 100644 --- a/pmd-java/src/main/resources/category/java/performance.xml +++ b/pmd-java/src/main/resources/category/java/performance.xml @@ -631,7 +631,7 @@ Note: This rule was named TooFewBranchesForASwitchStatement before PMD 7.7.0. //(SwitchStatement | SwitchExpression) [ (count(*) - 1) < $minimumNumberCaseForASwitch ] (: only consider if no pattern matching is used :) - [*/SwitchLabel[@PatternLabel = false()]] + [not(*/SwitchLabel[@PatternLabel = true()])] ]]> diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForSwitch.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForSwitch.xml index 502c470bc2..239aebbb12 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForSwitch.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForSwitch.xml @@ -4,6 +4,19 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests http://pmd.sourceforge.net/rule-tests_1_0_0.xsd"> + + Switch Statement with no case, not ok + 3 + 1 + + + Switch Statement with only one case, not ok 3 From 662759755d83ab0a515dc4b6651a0ca130cc399b Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 24 Oct 2024 12:47:44 +0200 Subject: [PATCH 41/52] [java] SwitchStmtsShouldHaveDefault.xml: don't report empty switch Empty switch statements are already reported by EmptyControlStatement --- docs/pages/release_notes.md | 2 ++ .../xml/SwitchStmtsShouldHaveDefault.xml | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 8adaca9a57..687894b8f0 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -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. diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/SwitchStmtsShouldHaveDefault.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/SwitchStmtsShouldHaveDefault.xml index cd13ce5dc9..eba1aef001 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/SwitchStmtsShouldHaveDefault.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/SwitchStmtsShouldHaveDefault.xml @@ -19,6 +19,19 @@ public class Foo { ]]> + + empty switch is ok + 0 + + + simple ok case 0 From 45b1217485bb712dd89c15077b98a4042975d226 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 24 Oct 2024 12:51:42 +0200 Subject: [PATCH 42/52] [java] TooFewBranchesForSwitch: don't report empty switch Empty switch statements are already reported by EmptyControlStatement --- docs/pages/release_notes.md | 2 ++ pmd-java/src/main/resources/category/java/performance.xml | 2 +- .../java/rule/performance/xml/TooFewBranchesForSwitch.xml | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 19769b9943..6fb4e5bdef 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -24,6 +24,8 @@ See [PR #5040](https://github.com/pmd/pmd/pull/5040) for details. ### 🌟 Rule Changes #### Changed Rules +* {% rule java/performance/TooFewBranchesForSwitch %} (Java Performance) doesn't report empty switches 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. diff --git a/pmd-java/src/main/resources/category/java/performance.xml b/pmd-java/src/main/resources/category/java/performance.xml index f2e7eef431..a8e4c37142 100644 --- a/pmd-java/src/main/resources/category/java/performance.xml +++ b/pmd-java/src/main/resources/category/java/performance.xml @@ -631,7 +631,7 @@ Note: This rule was named TooFewBranchesForASwitchStatement before PMD 7.7.0. //(SwitchStatement | SwitchExpression) [ (count(*) - 1) < $minimumNumberCaseForASwitch ] (: only consider if no pattern matching is used :) - [not(*/SwitchLabel[@PatternLabel = true()])] + [*/SwitchLabel[@PatternLabel = false()]] ]]> diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForSwitch.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForSwitch.xml index 239aebbb12..e603390ec6 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForSwitch.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/performance/xml/TooFewBranchesForSwitch.xml @@ -5,13 +5,13 @@ xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests http://pmd.sourceforge.net/rule-tests_1_0_0.xsd"> - Switch Statement with no case, not ok + Switch Statement with no case, ok 3 - 1 + 0 From 36654ed52ec9b8b5e9087ac523563dff6a2ea09f Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 24 Oct 2024 13:08:09 +0200 Subject: [PATCH 43/52] [java] UselessOperationOnImmutable: false positive on void results --- .../UselessOperationOnImmutableRule.java | 3 ++- .../errorprone/xml/UselessOperationOnImmutable.xml | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/UselessOperationOnImmutableRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/UselessOperationOnImmutableRule.java index c326446c5e..89434b830d 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/UselessOperationOnImmutableRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/UselessOperationOnImmutableRule.java @@ -30,7 +30,8 @@ public class UselessOperationOnImmutableRule extends AbstractJavaRulechainRule { @Override public Object visit(ASTMethodCall node, Object data) { ASTExpression qualifier = node.getQualifier(); - if (node.getParent() instanceof ASTExpressionStatement && qualifier != null) { + boolean returnsVoid = node.getTypeMirror().isVoid(); + if (node.getParent() instanceof ASTExpressionStatement && qualifier != null && !returnsVoid) { // these types are immutable, so any method of those whose // result is ignored is a violation diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/UselessOperationOnImmutable.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/UselessOperationOnImmutable.xml index b311af77f0..35ee48f112 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/UselessOperationOnImmutable.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/UselessOperationOnImmutable.xml @@ -318,6 +318,20 @@ class Tester { period = period.plusWeeks(1); // ok } } +]]> + + + + False positive for package private method calls in openjdk + 0 + From 5e83246469c4361af8d3bc9811a41a494bc6bf11 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 24 Oct 2024 14:16:43 +0200 Subject: [PATCH 44/52] [doc] Update release notes (#5267) --- docs/pages/release_notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index aac6ab6801..5f9c2500fa 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -52,6 +52,7 @@ The old rule names still work but are deprecated. * [#4965](https://github.com/pmd/pmd/pull/4965): \[java] Rename JUnit rules with overly restrictive names - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) * [#5225](https://github.com/pmd/pmd/pull/5225): \[java] Fix #5067: CloseResource: False positive for FileSystems.getDefault() - [Lukas Gräf](https://github.com/lukasgraef) (@lukasgraef) * [#5241](https://github.com/pmd/pmd/pull/5241): Ignore javacc code in coverage report - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) +* [#5267](https://github.com/pmd/pmd/pull/5267): \[java] Rename rule SwitchStmtsShouldHaveDefault to NonExhaustiveSwitch - [Andreas Dangel](https://github.com/adangel) (@adangel) {% endtocmaker %} From 919e73f6b0a509293c45ef1a03f6603b71339f6c Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 25 Oct 2024 08:47:38 +0200 Subject: [PATCH 45/52] Prepare pmd release 7.7.0 --- docs/_config.yml | 2 +- docs/pages/release_notes.md | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/_config.yml b/docs/_config.yml index 912d463cc1..bcfd087850 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -1,7 +1,7 @@ repository: pmd/pmd pmd: - version: 7.7.0-SNAPSHOT + version: 7.7.0 previous_version: 7.6.0 date: 2024-10-25 # release types: major, minor, bugfix diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index ddaf1fedd4..74899b4ea7 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -107,5 +107,16 @@ The old rule names still work but are deprecated. * [#5278](https://github.com/pmd/pmd/pull/5278): \[java] CouplingBetweenObjects: improve violation message - [Andreas Dangel](https://github.com/adangel) (@adangel) * [#5279](https://github.com/pmd/pmd/pull/5279): Fix #5244: \[java] UselessOperationOnImmutable: consider java.time.* types - [Andreas Dangel](https://github.com/adangel) (@adangel) -{% endtocmaker %} +### 📦 Dependency updates +* [#5234](https://github.com/pmd/pmd/issues/5234): Bump com.google.protobuf:protobuf-java from 3.25.3 to 4.28.2 +* [#5274](https://github.com/pmd/pmd/issues/5274): Bump org.junit from 5.8.2 to 5.11.2 +* [#5276](https://github.com/pmd/pmd/issues/5276): Bump org.checkerframework:checker-qual from 2.11.1 to 3.48.1 +* [#5280](https://github.com/pmd/pmd/issues/5280): Bump danger from 9.5.0 to 9.5.1 in the all-gems group across 1 directory +* [#5281](https://github.com/pmd/pmd/issues/5281): Bump org.scala-lang:scala-reflect from 2.13.13 to 2.13.15 +### 📈 Stats +* 98 commits +* 32 closed tickets & PRs +* Days since last release: 27 + +{% endtocmaker %} From 7739f2b840ca4b7116f126e714f1d05c32e84f44 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 25 Oct 2024 09:07:54 +0200 Subject: [PATCH 46/52] [release] prepare release pmd_releases/7.7.0 --- pmd-ant/pom.xml | 2 +- pmd-apex/pom.xml | 2 +- pmd-cli/pom.xml | 2 +- pmd-coco/pom.xml | 2 +- pmd-core/pom.xml | 2 +- pmd-cpp/pom.xml | 2 +- pmd-cs/pom.xml | 2 +- pmd-dart/pom.xml | 2 +- pmd-dist/pom.xml | 2 +- pmd-doc/pom.xml | 2 +- pmd-fortran/pom.xml | 2 +- pmd-gherkin/pom.xml | 2 +- pmd-go/pom.xml | 2 +- pmd-groovy/pom.xml | 2 +- pmd-html/pom.xml | 2 +- pmd-java/pom.xml | 2 +- pmd-javascript/pom.xml | 2 +- pmd-jsp/pom.xml | 2 +- pmd-julia/pom.xml | 2 +- pmd-kotlin/pom.xml | 2 +- pmd-lang-test/pom.xml | 2 +- pmd-languages-deps/pom.xml | 2 +- pmd-lua/pom.xml | 2 +- pmd-matlab/pom.xml | 2 +- pmd-modelica/pom.xml | 2 +- pmd-objectivec/pom.xml | 2 +- pmd-perl/pom.xml | 2 +- pmd-php/pom.xml | 2 +- pmd-plsql/pom.xml | 2 +- pmd-python/pom.xml | 2 +- pmd-ruby/pom.xml | 2 +- pmd-scala-modules/pmd-scala-common/pom.xml | 2 +- pmd-scala-modules/pmd-scala_2.12/pom.xml | 2 +- pmd-scala-modules/pmd-scala_2.13/pom.xml | 2 +- pmd-swift/pom.xml | 2 +- pmd-test-schema/pom.xml | 2 +- pmd-test/pom.xml | 2 +- pmd-tsql/pom.xml | 2 +- pmd-velocity/pom.xml | 2 +- pmd-visualforce/pom.xml | 2 +- pmd-xml/pom.xml | 2 +- pom.xml | 6 +++--- 42 files changed, 44 insertions(+), 44 deletions(-) diff --git a/pmd-ant/pom.xml b/pmd-ant/pom.xml index bc57065dc2..b78dde0c38 100644 --- a/pmd-ant/pom.xml +++ b/pmd-ant/pom.xml @@ -7,7 +7,7 @@ pmd net.sourceforge.pmd - 7.7.0-SNAPSHOT + 7.7.0 4.0.0 diff --git a/pmd-apex/pom.xml b/pmd-apex/pom.xml index 1c1c8045fe..260ed5f093 100644 --- a/pmd-apex/pom.xml +++ b/pmd-apex/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-cli/pom.xml b/pmd-cli/pom.xml index adca9527ba..9310e7d19a 100644 --- a/pmd-cli/pom.xml +++ b/pmd-cli/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-coco/pom.xml b/pmd-coco/pom.xml index 147966f7b6..b9d5c58f3c 100644 --- a/pmd-coco/pom.xml +++ b/pmd-coco/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-core/pom.xml b/pmd-core/pom.xml index 531a06515f..8e7fcc69fb 100644 --- a/pmd-core/pom.xml +++ b/pmd-core/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-cpp/pom.xml b/pmd-cpp/pom.xml index a42c4f850a..33d5a7fab5 100644 --- a/pmd-cpp/pom.xml +++ b/pmd-cpp/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-cs/pom.xml b/pmd-cs/pom.xml index 0eec39f809..ab65ef9f85 100644 --- a/pmd-cs/pom.xml +++ b/pmd-cs/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-dart/pom.xml b/pmd-dart/pom.xml index 496115127b..712a517fa9 100644 --- a/pmd-dart/pom.xml +++ b/pmd-dart/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-dist/pom.xml b/pmd-dist/pom.xml index 9ad286e9a4..d678afd804 100644 --- a/pmd-dist/pom.xml +++ b/pmd-dist/pom.xml @@ -8,7 +8,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-doc/pom.xml b/pmd-doc/pom.xml index c0b7991017..9cd4cce3a5 100644 --- a/pmd-doc/pom.xml +++ b/pmd-doc/pom.xml @@ -8,7 +8,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-fortran/pom.xml b/pmd-fortran/pom.xml index 94bc7d94bd..d0e8d2d0a3 100644 --- a/pmd-fortran/pom.xml +++ b/pmd-fortran/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-gherkin/pom.xml b/pmd-gherkin/pom.xml index 6aee2c1be5..962c5df4e3 100644 --- a/pmd-gherkin/pom.xml +++ b/pmd-gherkin/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-go/pom.xml b/pmd-go/pom.xml index 4df297ebc9..d6c1f307d1 100644 --- a/pmd-go/pom.xml +++ b/pmd-go/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-groovy/pom.xml b/pmd-groovy/pom.xml index bf716ac77c..d0a6a86166 100644 --- a/pmd-groovy/pom.xml +++ b/pmd-groovy/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-html/pom.xml b/pmd-html/pom.xml index 86f19c7c01..f69377fd48 100644 --- a/pmd-html/pom.xml +++ b/pmd-html/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-java/pom.xml b/pmd-java/pom.xml index 2d82829d15..684357d311 100644 --- a/pmd-java/pom.xml +++ b/pmd-java/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-javascript/pom.xml b/pmd-javascript/pom.xml index ea4d55938d..e2c573e60d 100644 --- a/pmd-javascript/pom.xml +++ b/pmd-javascript/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-jsp/pom.xml b/pmd-jsp/pom.xml index 790d5353f8..309b937a72 100644 --- a/pmd-jsp/pom.xml +++ b/pmd-jsp/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-julia/pom.xml b/pmd-julia/pom.xml index ac3ed6eed1..c0274b3394 100644 --- a/pmd-julia/pom.xml +++ b/pmd-julia/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-kotlin/pom.xml b/pmd-kotlin/pom.xml index 40f19513de..74801b5840 100644 --- a/pmd-kotlin/pom.xml +++ b/pmd-kotlin/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-lang-test/pom.xml b/pmd-lang-test/pom.xml index 49f8aade09..97faed1615 100644 --- a/pmd-lang-test/pom.xml +++ b/pmd-lang-test/pom.xml @@ -12,7 +12,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-languages-deps/pom.xml b/pmd-languages-deps/pom.xml index 38f0d009e8..4585d63162 100644 --- a/pmd-languages-deps/pom.xml +++ b/pmd-languages-deps/pom.xml @@ -4,7 +4,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 pmd-languages-deps diff --git a/pmd-lua/pom.xml b/pmd-lua/pom.xml index f3a24be6d3..da97fbb64c 100644 --- a/pmd-lua/pom.xml +++ b/pmd-lua/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-matlab/pom.xml b/pmd-matlab/pom.xml index 42a69e2497..2cece277f7 100644 --- a/pmd-matlab/pom.xml +++ b/pmd-matlab/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-modelica/pom.xml b/pmd-modelica/pom.xml index d551bc25a1..2a68dbbd51 100644 --- a/pmd-modelica/pom.xml +++ b/pmd-modelica/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-objectivec/pom.xml b/pmd-objectivec/pom.xml index 197c6dac58..c8b75bb765 100644 --- a/pmd-objectivec/pom.xml +++ b/pmd-objectivec/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-perl/pom.xml b/pmd-perl/pom.xml index 3cb972b403..8bb50a572d 100644 --- a/pmd-perl/pom.xml +++ b/pmd-perl/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-php/pom.xml b/pmd-php/pom.xml index 88f09db7a4..6ba5c6d9dc 100644 --- a/pmd-php/pom.xml +++ b/pmd-php/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-plsql/pom.xml b/pmd-plsql/pom.xml index 26a5614255..0d427df186 100644 --- a/pmd-plsql/pom.xml +++ b/pmd-plsql/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-python/pom.xml b/pmd-python/pom.xml index 30326faeeb..11975a4348 100644 --- a/pmd-python/pom.xml +++ b/pmd-python/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-ruby/pom.xml b/pmd-ruby/pom.xml index 9acaabbf96..41684ffbe7 100644 --- a/pmd-ruby/pom.xml +++ b/pmd-ruby/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-scala-modules/pmd-scala-common/pom.xml b/pmd-scala-modules/pmd-scala-common/pom.xml index 80ad4da7bd..e220e39d7a 100644 --- a/pmd-scala-modules/pmd-scala-common/pom.xml +++ b/pmd-scala-modules/pmd-scala-common/pom.xml @@ -8,7 +8,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../../pom.xml diff --git a/pmd-scala-modules/pmd-scala_2.12/pom.xml b/pmd-scala-modules/pmd-scala_2.12/pom.xml index 3f73f1cbfb..f18e317508 100644 --- a/pmd-scala-modules/pmd-scala_2.12/pom.xml +++ b/pmd-scala-modules/pmd-scala_2.12/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd-scala-common - 7.7.0-SNAPSHOT + 7.7.0 ../pmd-scala-common/pom.xml diff --git a/pmd-scala-modules/pmd-scala_2.13/pom.xml b/pmd-scala-modules/pmd-scala_2.13/pom.xml index ee66fca93a..c72f6c3a8e 100644 --- a/pmd-scala-modules/pmd-scala_2.13/pom.xml +++ b/pmd-scala-modules/pmd-scala_2.13/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd-scala-common - 7.7.0-SNAPSHOT + 7.7.0 ../pmd-scala-common/pom.xml diff --git a/pmd-swift/pom.xml b/pmd-swift/pom.xml index 023fa8dd39..9f3e7cfb0f 100644 --- a/pmd-swift/pom.xml +++ b/pmd-swift/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-test-schema/pom.xml b/pmd-test-schema/pom.xml index 43a990e8dc..eba0a7ae73 100644 --- a/pmd-test-schema/pom.xml +++ b/pmd-test-schema/pom.xml @@ -11,7 +11,7 @@ pmd net.sourceforge.pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-test/pom.xml b/pmd-test/pom.xml index 0fd57a4437..626b390eaa 100644 --- a/pmd-test/pom.xml +++ b/pmd-test/pom.xml @@ -8,7 +8,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-tsql/pom.xml b/pmd-tsql/pom.xml index e3a2489eff..0ca382140f 100644 --- a/pmd-tsql/pom.xml +++ b/pmd-tsql/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-velocity/pom.xml b/pmd-velocity/pom.xml index 905cd6b41c..371a275b88 100644 --- a/pmd-velocity/pom.xml +++ b/pmd-velocity/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-visualforce/pom.xml b/pmd-visualforce/pom.xml index 164795a623..19548ea836 100644 --- a/pmd-visualforce/pom.xml +++ b/pmd-visualforce/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pmd-xml/pom.xml b/pmd-xml/pom.xml index 1d19200b86..8b91ba5ca1 100644 --- a/pmd-xml/pom.xml +++ b/pmd-xml/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 ../pom.xml diff --git a/pom.xml b/pom.xml index de14b5c3ae..81f600916c 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 net.sourceforge.pmd pmd - 7.7.0-SNAPSHOT + 7.7.0 pom PMD @@ -62,7 +62,7 @@ scm:git:git://github.com/pmd/pmd.git scm:git:ssh://git@github.com/pmd/pmd.git https://github.com/pmd/pmd - HEAD + pmd_releases/7.7.0 @@ -83,7 +83,7 @@ - 2024-09-27T08:50:09Z + 2024-10-25T06:47:53Z 8 From c179834288643e64985ce8885ad537670e4b23c6 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 25 Oct 2024 09:28:54 +0200 Subject: [PATCH 47/52] [release] Prepare next development version [skip ci] --- docs/_config.yml | 6 +- docs/pages/release_notes.md | 102 +---------------- docs/pages/release_notes_old.md | 126 +++++++++++++++++++++ pmd-ant/pom.xml | 2 +- pmd-apex/pom.xml | 2 +- pmd-cli/pom.xml | 2 +- pmd-coco/pom.xml | 2 +- pmd-core/pom.xml | 2 +- pmd-cpp/pom.xml | 2 +- pmd-cs/pom.xml | 2 +- pmd-dart/pom.xml | 2 +- pmd-dist/pom.xml | 2 +- pmd-doc/pom.xml | 2 +- pmd-fortran/pom.xml | 2 +- pmd-gherkin/pom.xml | 2 +- pmd-go/pom.xml | 2 +- pmd-groovy/pom.xml | 2 +- pmd-html/pom.xml | 2 +- pmd-java/pom.xml | 2 +- pmd-javascript/pom.xml | 2 +- pmd-jsp/pom.xml | 2 +- pmd-julia/pom.xml | 2 +- pmd-kotlin/pom.xml | 2 +- pmd-lang-test/pom.xml | 2 +- pmd-languages-deps/pom.xml | 2 +- pmd-lua/pom.xml | 2 +- pmd-matlab/pom.xml | 2 +- pmd-modelica/pom.xml | 2 +- pmd-objectivec/pom.xml | 2 +- pmd-perl/pom.xml | 2 +- pmd-php/pom.xml | 2 +- pmd-plsql/pom.xml | 2 +- pmd-python/pom.xml | 2 +- pmd-ruby/pom.xml | 2 +- pmd-scala-modules/pmd-scala-common/pom.xml | 2 +- pmd-scala-modules/pmd-scala_2.12/pom.xml | 2 +- pmd-scala-modules/pmd-scala_2.13/pom.xml | 2 +- pmd-swift/pom.xml | 2 +- pmd-test-schema/pom.xml | 2 +- pmd-test/pom.xml | 2 +- pmd-tsql/pom.xml | 2 +- pmd-velocity/pom.xml | 2 +- pmd-visualforce/pom.xml | 2 +- pmd-xml/pom.xml | 2 +- pom.xml | 4 +- 45 files changed, 174 insertions(+), 146 deletions(-) diff --git a/docs/_config.yml b/docs/_config.yml index bcfd087850..27190ef965 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -1,9 +1,9 @@ repository: pmd/pmd pmd: - version: 7.7.0 - previous_version: 7.6.0 - date: 2024-10-25 + version: 7.8.0-SNAPSHOT + previous_version: 7.7.0 + date: 2024-11-29 # release types: major, minor, bugfix release_type: minor diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 74899b4ea7..bc1a36ec7a 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -14,109 +14,11 @@ This is a {{ site.pmd.release_type }} release. ### 🚀 New and noteworthy -#### CPD can now ignore literals and identifiers in C++ code - -When searching for duplicated code in C++ differences in literals or identifiers can be -ignored now (like in Java). This can be enabled via the command line options `--ignore-literal` -and `--ignore-identifiers`. -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. -* {% rule java/performance/TooFewBranchesForSwitch %} (Java Performance) doesn't report empty switches anymore. - To detect these, use {% rule java/codestyle/EmptyControlStatement %}. - -#### 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 about switch statements and switch expression have been renamed, as they apply both to Switch Statements - and to Switch Expressions: - * {% rule java/bestpractices/DefaultLabelNotLastInSwitch %} (Java Best Practices) has been renamed from `DefaultLabelNotLastInSwitch`. - * {% rule java/errorprone/NonCaseLabelInSwitch %} (Java Error Prone) has been renamed from `NonCaseLabelInSwitchStatement`. - * {% rule java/performance/TooFewBranchesForSwitch %} (Java Performance) has been renamed from `TooFewBranchesForASwitchStatement`. - * {% rule java/bestpractices/NonExhaustiveSwitch %} (Java Best Practices) has been renamed from `SwitchStmtsShouldHaveDefault`. - -The old rule names still work but are deprecated. - ### 🐛 Fixed Issues -* apex-performance - * [#5270](https://github.com/pmd/pmd/issues/5270): \[apex] AvoidNonRestrictiveQueries when LIMIT is followed by bind expression -* java - * [#4532](https://github.com/pmd/pmd/issues/4532): \[java] Rule misnomer for JUnit* rules - * [#5261](https://github.com/pmd/pmd/issues/5261): \[java] Record patterns with empty deconstructor lists lead to NPE -* java-bestpractices - * [#4286](https://github.com/pmd/pmd/issues/4286): \[java] Rename rule SwitchStmtsShouldHaveDefault to NonExhaustiveSwitch - * [#4813](https://github.com/pmd/pmd/issues/4813): \[java] SwitchStmtsShouldHaveDefault false positive with pattern matching -* java-codestyle - * [#5253](https://github.com/pmd/pmd/issues/5253): \[java] BooleanGetMethodName: False-negatives with `Boolean` wrapper -* java-design - * [#5030](https://github.com/pmd/pmd/issues/5030): \[java] SwitchDensity false positive with pattern matching -* java-errorprone - * [#3362](https://github.com/pmd/pmd/issues/3362): \[java] ImplicitSwitchFallThrough should consider switch expressions - * [#5067](https://github.com/pmd/pmd/issues/5067): \[java] CloseResource: False positive for FileSystems.getDefault() - * [#5244](https://github.com/pmd/pmd/issues/5244): \[java] UselessOperationOnImmutable should detect java.time types - * [#5257](https://github.com/pmd/pmd/issues/5257): \[java] NonCaseLabelInSwitch should consider switch expressions -* java-performance - * [#5249](https://github.com/pmd/pmd/issues/5249): \[java] TooFewBranchesForASwitchStatement false positive for Pattern Matching - * [#5250](https://github.com/pmd/pmd/issues/5250): \[java] TooFewBranchesForASwitchStatement should consider Switch Expressions ### 🚨 API Changes -* java-bestpractices - * The old rule name `JUnit4TestShouldUseAfterAnnotation` has been deprecated. Use the new name {% rule java/bestpractices/UnitTestShouldUseAfterAnnotation %} instead. - * The old rule name `JUnit4TestShouldUseBeforeAnnotation` has been deprecated. Use the new name {% rule java/bestpractices/UnitTestShouldUseBeforeAnnotation %} instead. - * The old rule name `JUnit4TestShouldUseTestAnnotation` has been deprecated. Use the new name {% rule java/bestpractices/UnitTestShouldUseTestAnnotation %} instead. - * 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. - * The old rule name `DefaultLabelNotLastInSwitch` has been deprecated. Use the new name {% rule java/bestpractices/DefaultLabelNotLastInSwitch %} instead. - * The old rule name `SwitchStmtsShouldHaveDefault` has been deprecated. USe the new name {%rule java/bestpractices/NonExhaustiveSwitch %} instead. -* java-errorprone - * The old rule name `NonCaseLabelInSwitchStatement` has been deprecated. Use the new name {% rule java/errorprone/NonCaseLabelInSwitch %} instead. -* java-performance - * The old rule name `TooFewBranchesForASwitchStatement` has been deprecated. Use the new name {% rule java/performance/TooFewBranchesForSwitch %} instead. -### ✨ Merged pull requests -* [#4965](https://github.com/pmd/pmd/pull/4965): Fix #4532: \[java] Rename JUnit rules with overly restrictive names - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) -* [#5040](https://github.com/pmd/pmd/pull/5040): \[cpp] Ignore literals and ignore identifiers capability to C++ CPD - [Jakub Dupak](https://github.com/jdupak) (@jdupak) -* [#5225](https://github.com/pmd/pmd/pull/5225): Fix #5067: \[java] CloseResource: False positive for FileSystems.getDefault() - [Lukas Gräf](https://github.com/lukasgraef) (@lukasgraef) -* [#5241](https://github.com/pmd/pmd/pull/5241): Ignore javacc code in coverage report - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) -* [#5245](https://github.com/pmd/pmd/pull/5245): \[java] Improve UnitTestShouldUse{After,Before}Annotation rules to support JUnit5 and TestNG - [Andreas Dangel](https://github.com/adangel) (@adangel) -* [#5247](https://github.com/pmd/pmd/pull/5247): Fix #5030: \[java] SwitchDensity false positive with pattern matching - [Andreas Dangel](https://github.com/adangel) (@adangel) -* [#5248](https://github.com/pmd/pmd/pull/5248): Fix #3362: \[java] ImplicitSwitchFallThrough should consider switch expressions - [Andreas Dangel](https://github.com/adangel) (@adangel) -* [#5251](https://github.com/pmd/pmd/pull/5251): Fix #5249 and #5250: \[java] TooFewBranchesForSwitch ignore pattern matching and support switch expressions - [Andreas Dangel](https://github.com/adangel) (@adangel) -* [#5252](https://github.com/pmd/pmd/pull/5252): Fix #4813: \[java] SwitchStmtsShouldHaveDefault false positive with pattern matching - [Andreas Dangel](https://github.com/adangel) (@adangel) -* [#5255](https://github.com/pmd/pmd/pull/5255): \[java] Rename rule DefaultLabelNotLastInSwitch - [Andreas Dangel](https://github.com/adangel) (@adangel) -* [#5256](https://github.com/pmd/pmd/pull/5256): Fix #5257: \[java] NonCaseLabelInSwitch - support switch expressions - [Andreas Dangel](https://github.com/adangel) (@adangel) -* [#5258](https://github.com/pmd/pmd/pull/5258): Ignore generated antlr classes in coverage reports - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) -* [#5264](https://github.com/pmd/pmd/pull/5264): Fix #5261: \[java] Fix NPE with empty pattern list - [Clément Fournier](https://github.com/oowekyala) (@oowekyala) -* [#5267](https://github.com/pmd/pmd/pull/5267): \[java] Rename rule SwitchStmtsShouldHaveDefault to NonExhaustiveSwitch - [Andreas Dangel](https://github.com/adangel) (@adangel) -* [#5269](https://github.com/pmd/pmd/pull/5269): Fix #5253: \[java] Support Boolean wrapper class for BooleanGetMethodName rule - [Aryant Tripathi](https://github.com/Aryant-Tripathi) (@Aryant-Tripathi) -* [#5273](https://github.com/pmd/pmd/pull/5273): Fix #5270: \[apex] AvoidNonRestrictiveQueries: Fix regex for detecting LIMIT clause - [Andreas Dangel](https://github.com/adangel) (@adangel) -* [#5275](https://github.com/pmd/pmd/pull/5275): Use plugin-classpath to simplify javacc-wrapper.xml - [Andreas Dangel](https://github.com/adangel) (@adangel) -* [#5278](https://github.com/pmd/pmd/pull/5278): \[java] CouplingBetweenObjects: improve violation message - [Andreas Dangel](https://github.com/adangel) (@adangel) -* [#5279](https://github.com/pmd/pmd/pull/5279): Fix #5244: \[java] UselessOperationOnImmutable: consider java.time.* types - [Andreas Dangel](https://github.com/adangel) (@adangel) - -### 📦 Dependency updates -* [#5234](https://github.com/pmd/pmd/issues/5234): Bump com.google.protobuf:protobuf-java from 3.25.3 to 4.28.2 -* [#5274](https://github.com/pmd/pmd/issues/5274): Bump org.junit from 5.8.2 to 5.11.2 -* [#5276](https://github.com/pmd/pmd/issues/5276): Bump org.checkerframework:checker-qual from 2.11.1 to 3.48.1 -* [#5280](https://github.com/pmd/pmd/issues/5280): Bump danger from 9.5.0 to 9.5.1 in the all-gems group across 1 directory -* [#5281](https://github.com/pmd/pmd/issues/5281): Bump org.scala-lang:scala-reflect from 2.13.13 to 2.13.15 - -### 📈 Stats -* 98 commits -* 32 closed tickets & PRs -* Days since last release: 27 +### ✨ External Contributions {% endtocmaker %} + diff --git a/docs/pages/release_notes_old.md b/docs/pages/release_notes_old.md index 6a7983db8b..e55197097a 100644 --- a/docs/pages/release_notes_old.md +++ b/docs/pages/release_notes_old.md @@ -5,6 +5,132 @@ permalink: pmd_release_notes_old.html Previous versions of PMD can be downloaded here: [Releases - pmd/pmd (GitHub)](https://github.com/pmd/pmd/releases) +## 25-October-2024 - 7.7.0 + +The PMD team is pleased to announce PMD 7.7.0. + +This is a minor release. + +### Table Of Contents + +* [🚀 New and noteworthy](#new-and-noteworthy) + * [CPD can now ignore literals and identifiers in C++ code](#cpd-can-now-ignore-literals-and-identifiers-in-c-code) +* [🌟 Rule Changes](#rule-changes) + * [Changed Rules](#changed-rules) + * [Renamed Rules](#renamed-rules) +* [🐛 Fixed Issues](#fixed-issues) +* [🚨 API Changes](#api-changes) +* [✨ Merged pull requests](#merged-pull-requests) +* [📦 Dependency updates](#dependency-updates) +* [📈 Stats](#stats) + +### 🚀 New and noteworthy + +#### CPD can now ignore literals and identifiers in C++ code + +When searching for duplicated code in C++ differences in literals or identifiers can be +ignored now (like in Java). This can be enabled via the command line options `--ignore-literal` +and `--ignore-identifiers`. +See [PR #5040](https://github.com/pmd/pmd/pull/5040) for details. + +### 🌟 Rule Changes + +#### Changed Rules +* [`SwitchStmtsShouldHaveDefault`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#switchstmtsshouldhavedefault) (Java Best Practices) doesn't report empty switch statements anymore. + To detect these, use [`EmptyControlStatement`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_codestyle.html#emptycontrolstatement). +* [`UnitTestShouldUseAfterAnnotation`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestshoulduseafterannotation) (Java Best Practices) now also considers JUnit 5 and TestNG tests. +* [`UnitTestShouldUseBeforeAnnotation`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestshouldusebeforeannotation) (Java Best Practices) now also considers JUnit 5 and TestNG tests. +* [`TooFewBranchesForSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_performance.html#toofewbranchesforswitch) (Java Performance) doesn't report empty switches anymore. + To detect these, use [`EmptyControlStatement`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_codestyle.html#emptycontrolstatement). + +#### 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. + * [`UnitTestAssertionsShouldIncludeMessage`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestassertionsshouldincludemessage) (Java Best Practices) has been renamed from `JUnitAssertionsShouldIncludeMessage`. + * [`UnitTestContainsTooManyAsserts`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestcontainstoomanyasserts) (Java Best Practices) has been renamed from `JUnitTestContainsTooManyAsserts`. + * [`UnitTestShouldIncludeAssert`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestshouldincludeassert) (Java Best Practices) has been renamed from `JUnitTestsShouldIncludeAssert`. + * [`UnitTestShouldUseAfterAnnotation`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestshoulduseafterannotation) (Java Best Practices) has been renamed from `JUnit4TestShouldUseAfterAnnotation`. + * [`UnitTestShouldUseBeforeAnnotation`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestshouldusebeforeannotation) (Java Best Practices) has been renamed from `JUnit4TestShouldUseBeforeAnnotation`. + * [`UnitTestShouldUseTestAnnotation`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestshouldusetestannotation) (Java Best Practices) has been renamed from `JUnit4TestShouldUseTestAnnotation`. +* Several rules about switch statements and switch expression have been renamed, as they apply both to Switch Statements + and to Switch Expressions: + * [`DefaultLabelNotLastInSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#defaultlabelnotlastinswitch) (Java Best Practices) has been renamed from `DefaultLabelNotLastInSwitch`. + * [`NonCaseLabelInSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_errorprone.html#noncaselabelinswitch) (Java Error Prone) has been renamed from `NonCaseLabelInSwitchStatement`. + * [`TooFewBranchesForSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_performance.html#toofewbranchesforswitch) (Java Performance) has been renamed from `TooFewBranchesForASwitchStatement`. + * [`NonExhaustiveSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#nonexhaustiveswitch) (Java Best Practices) has been renamed from `SwitchStmtsShouldHaveDefault`. + +The old rule names still work but are deprecated. + +### 🐛 Fixed Issues +* apex-performance + * [#5270](https://github.com/pmd/pmd/issues/5270): \[apex] AvoidNonRestrictiveQueries when LIMIT is followed by bind expression +* java + * [#4532](https://github.com/pmd/pmd/issues/4532): \[java] Rule misnomer for JUnit* rules + * [#5261](https://github.com/pmd/pmd/issues/5261): \[java] Record patterns with empty deconstructor lists lead to NPE +* java-bestpractices + * [#4286](https://github.com/pmd/pmd/issues/4286): \[java] Rename rule SwitchStmtsShouldHaveDefault to NonExhaustiveSwitch + * [#4813](https://github.com/pmd/pmd/issues/4813): \[java] SwitchStmtsShouldHaveDefault false positive with pattern matching +* java-codestyle + * [#5253](https://github.com/pmd/pmd/issues/5253): \[java] BooleanGetMethodName: False-negatives with `Boolean` wrapper +* java-design + * [#5030](https://github.com/pmd/pmd/issues/5030): \[java] SwitchDensity false positive with pattern matching +* java-errorprone + * [#3362](https://github.com/pmd/pmd/issues/3362): \[java] ImplicitSwitchFallThrough should consider switch expressions + * [#5067](https://github.com/pmd/pmd/issues/5067): \[java] CloseResource: False positive for FileSystems.getDefault() + * [#5244](https://github.com/pmd/pmd/issues/5244): \[java] UselessOperationOnImmutable should detect java.time types + * [#5257](https://github.com/pmd/pmd/issues/5257): \[java] NonCaseLabelInSwitch should consider switch expressions +* java-performance + * [#5249](https://github.com/pmd/pmd/issues/5249): \[java] TooFewBranchesForASwitchStatement false positive for Pattern Matching + * [#5250](https://github.com/pmd/pmd/issues/5250): \[java] TooFewBranchesForASwitchStatement should consider Switch Expressions + +### 🚨 API Changes +* java-bestpractices + * The old rule name `JUnit4TestShouldUseAfterAnnotation` has been deprecated. Use the new name [`UnitTestShouldUseAfterAnnotation`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestshoulduseafterannotation) instead. + * The old rule name `JUnit4TestShouldUseBeforeAnnotation` has been deprecated. Use the new name [`UnitTestShouldUseBeforeAnnotation`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestshouldusebeforeannotation) instead. + * The old rule name `JUnit4TestShouldUseTestAnnotation` has been deprecated. Use the new name [`UnitTestShouldUseTestAnnotation`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestshouldusetestannotation) instead. + * The old rule name `JUnitAssertionsShouldIncludeMessage` has been deprecated. Use the new name [`UnitTestAssertionsShouldIncludeMessage`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestassertionsshouldincludemessage) instead. + * The old rule name `JUnitTestContainsTooManyAsserts` has been deprecated. Use the new name [`UnitTestContainsTooManyAsserts`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestcontainstoomanyasserts) instead. + * The old rule name `JUnitTestsShouldIncludeAssert` has been deprecated. Use the new name [`UnitTestShouldIncludeAssert`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestshouldincludeassert) instead. + * The old rule name `DefaultLabelNotLastInSwitch` has been deprecated. Use the new name [`DefaultLabelNotLastInSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#defaultlabelnotlastinswitch) instead. + * The old rule name `SwitchStmtsShouldHaveDefault` has been deprecated. USe the new name [`NonExhaustiveSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#nonexhaustiveswitch) instead. +* java-errorprone + * The old rule name `NonCaseLabelInSwitchStatement` has been deprecated. Use the new name [`NonCaseLabelInSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_errorprone.html#noncaselabelinswitch) instead. +* java-performance + * The old rule name `TooFewBranchesForASwitchStatement` has been deprecated. Use the new name [`TooFewBranchesForSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_performance.html#toofewbranchesforswitch) instead. + +### ✨ Merged pull requests +* [#4965](https://github.com/pmd/pmd/pull/4965): Fix #4532: \[java] Rename JUnit rules with overly restrictive names - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) +* [#5040](https://github.com/pmd/pmd/pull/5040): \[cpp] Ignore literals and ignore identifiers capability to C++ CPD - [Jakub Dupak](https://github.com/jdupak) (@jdupak) +* [#5225](https://github.com/pmd/pmd/pull/5225): Fix #5067: \[java] CloseResource: False positive for FileSystems.getDefault() - [Lukas Gräf](https://github.com/lukasgraef) (@lukasgraef) +* [#5241](https://github.com/pmd/pmd/pull/5241): Ignore javacc code in coverage report - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) +* [#5245](https://github.com/pmd/pmd/pull/5245): \[java] Improve UnitTestShouldUse{After,Before}Annotation rules to support JUnit5 and TestNG - [Andreas Dangel](https://github.com/adangel) (@adangel) +* [#5247](https://github.com/pmd/pmd/pull/5247): Fix #5030: \[java] SwitchDensity false positive with pattern matching - [Andreas Dangel](https://github.com/adangel) (@adangel) +* [#5248](https://github.com/pmd/pmd/pull/5248): Fix #3362: \[java] ImplicitSwitchFallThrough should consider switch expressions - [Andreas Dangel](https://github.com/adangel) (@adangel) +* [#5251](https://github.com/pmd/pmd/pull/5251): Fix #5249 and #5250: \[java] TooFewBranchesForSwitch ignore pattern matching and support switch expressions - [Andreas Dangel](https://github.com/adangel) (@adangel) +* [#5252](https://github.com/pmd/pmd/pull/5252): Fix #4813: \[java] SwitchStmtsShouldHaveDefault false positive with pattern matching - [Andreas Dangel](https://github.com/adangel) (@adangel) +* [#5255](https://github.com/pmd/pmd/pull/5255): \[java] Rename rule DefaultLabelNotLastInSwitch - [Andreas Dangel](https://github.com/adangel) (@adangel) +* [#5256](https://github.com/pmd/pmd/pull/5256): Fix #5257: \[java] NonCaseLabelInSwitch - support switch expressions - [Andreas Dangel](https://github.com/adangel) (@adangel) +* [#5258](https://github.com/pmd/pmd/pull/5258): Ignore generated antlr classes in coverage reports - [Juan Martín Sotuyo Dodero](https://github.com/jsotuyod) (@jsotuyod) +* [#5264](https://github.com/pmd/pmd/pull/5264): Fix #5261: \[java] Fix NPE with empty pattern list - [Clément Fournier](https://github.com/oowekyala) (@oowekyala) +* [#5267](https://github.com/pmd/pmd/pull/5267): \[java] Rename rule SwitchStmtsShouldHaveDefault to NonExhaustiveSwitch - [Andreas Dangel](https://github.com/adangel) (@adangel) +* [#5269](https://github.com/pmd/pmd/pull/5269): Fix #5253: \[java] Support Boolean wrapper class for BooleanGetMethodName rule - [Aryant Tripathi](https://github.com/Aryant-Tripathi) (@Aryant-Tripathi) +* [#5273](https://github.com/pmd/pmd/pull/5273): Fix #5270: \[apex] AvoidNonRestrictiveQueries: Fix regex for detecting LIMIT clause - [Andreas Dangel](https://github.com/adangel) (@adangel) +* [#5275](https://github.com/pmd/pmd/pull/5275): Use plugin-classpath to simplify javacc-wrapper.xml - [Andreas Dangel](https://github.com/adangel) (@adangel) +* [#5278](https://github.com/pmd/pmd/pull/5278): \[java] CouplingBetweenObjects: improve violation message - [Andreas Dangel](https://github.com/adangel) (@adangel) +* [#5279](https://github.com/pmd/pmd/pull/5279): Fix #5244: \[java] UselessOperationOnImmutable: consider java.time.* types - [Andreas Dangel](https://github.com/adangel) (@adangel) + +### 📦 Dependency updates +* [#5234](https://github.com/pmd/pmd/issues/5234): Bump com.google.protobuf:protobuf-java from 3.25.3 to 4.28.2 +* [#5274](https://github.com/pmd/pmd/issues/5274): Bump org.junit from 5.8.2 to 5.11.2 +* [#5276](https://github.com/pmd/pmd/issues/5276): Bump org.checkerframework:checker-qual from 2.11.1 to 3.48.1 +* [#5280](https://github.com/pmd/pmd/issues/5280): Bump danger from 9.5.0 to 9.5.1 in the all-gems group across 1 directory +* [#5281](https://github.com/pmd/pmd/issues/5281): Bump org.scala-lang:scala-reflect from 2.13.13 to 2.13.15 + +### 📈 Stats +* 98 commits +* 32 closed tickets & PRs +* Days since last release: 27 + ## 27-September-2024 - 7.6.0 The PMD team is pleased to announce PMD 7.6.0. diff --git a/pmd-ant/pom.xml b/pmd-ant/pom.xml index b78dde0c38..6f6d37badf 100644 --- a/pmd-ant/pom.xml +++ b/pmd-ant/pom.xml @@ -7,7 +7,7 @@ pmd net.sourceforge.pmd - 7.7.0 + 7.8.0-SNAPSHOT 4.0.0 diff --git a/pmd-apex/pom.xml b/pmd-apex/pom.xml index 260ed5f093..4bcd6b9199 100644 --- a/pmd-apex/pom.xml +++ b/pmd-apex/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-cli/pom.xml b/pmd-cli/pom.xml index 9310e7d19a..c75f5f91fe 100644 --- a/pmd-cli/pom.xml +++ b/pmd-cli/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-coco/pom.xml b/pmd-coco/pom.xml index b9d5c58f3c..c060429a45 100644 --- a/pmd-coco/pom.xml +++ b/pmd-coco/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-core/pom.xml b/pmd-core/pom.xml index 8e7fcc69fb..e84a30f8c9 100644 --- a/pmd-core/pom.xml +++ b/pmd-core/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-cpp/pom.xml b/pmd-cpp/pom.xml index 33d5a7fab5..5c75467663 100644 --- a/pmd-cpp/pom.xml +++ b/pmd-cpp/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-cs/pom.xml b/pmd-cs/pom.xml index ab65ef9f85..97580cbf23 100644 --- a/pmd-cs/pom.xml +++ b/pmd-cs/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-dart/pom.xml b/pmd-dart/pom.xml index 712a517fa9..3cc180bb9c 100644 --- a/pmd-dart/pom.xml +++ b/pmd-dart/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-dist/pom.xml b/pmd-dist/pom.xml index d678afd804..7bfaf114e5 100644 --- a/pmd-dist/pom.xml +++ b/pmd-dist/pom.xml @@ -8,7 +8,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-doc/pom.xml b/pmd-doc/pom.xml index 9cd4cce3a5..4a6b36ac2e 100644 --- a/pmd-doc/pom.xml +++ b/pmd-doc/pom.xml @@ -8,7 +8,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-fortran/pom.xml b/pmd-fortran/pom.xml index d0e8d2d0a3..fac80382f4 100644 --- a/pmd-fortran/pom.xml +++ b/pmd-fortran/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-gherkin/pom.xml b/pmd-gherkin/pom.xml index 962c5df4e3..2c79671490 100644 --- a/pmd-gherkin/pom.xml +++ b/pmd-gherkin/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-go/pom.xml b/pmd-go/pom.xml index d6c1f307d1..aef9290837 100644 --- a/pmd-go/pom.xml +++ b/pmd-go/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-groovy/pom.xml b/pmd-groovy/pom.xml index d0a6a86166..1ffd4b60f4 100644 --- a/pmd-groovy/pom.xml +++ b/pmd-groovy/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-html/pom.xml b/pmd-html/pom.xml index f69377fd48..51cffc8823 100644 --- a/pmd-html/pom.xml +++ b/pmd-html/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-java/pom.xml b/pmd-java/pom.xml index 684357d311..184e6ece62 100644 --- a/pmd-java/pom.xml +++ b/pmd-java/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-javascript/pom.xml b/pmd-javascript/pom.xml index e2c573e60d..bb46814cfc 100644 --- a/pmd-javascript/pom.xml +++ b/pmd-javascript/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-jsp/pom.xml b/pmd-jsp/pom.xml index 309b937a72..749144cd60 100644 --- a/pmd-jsp/pom.xml +++ b/pmd-jsp/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-julia/pom.xml b/pmd-julia/pom.xml index c0274b3394..2dae0d4d57 100644 --- a/pmd-julia/pom.xml +++ b/pmd-julia/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-kotlin/pom.xml b/pmd-kotlin/pom.xml index 74801b5840..db57e02584 100644 --- a/pmd-kotlin/pom.xml +++ b/pmd-kotlin/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-lang-test/pom.xml b/pmd-lang-test/pom.xml index 97faed1615..6b32cbca37 100644 --- a/pmd-lang-test/pom.xml +++ b/pmd-lang-test/pom.xml @@ -12,7 +12,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-languages-deps/pom.xml b/pmd-languages-deps/pom.xml index 4585d63162..31428dbacc 100644 --- a/pmd-languages-deps/pom.xml +++ b/pmd-languages-deps/pom.xml @@ -4,7 +4,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT pmd-languages-deps diff --git a/pmd-lua/pom.xml b/pmd-lua/pom.xml index da97fbb64c..1a5924d3f6 100644 --- a/pmd-lua/pom.xml +++ b/pmd-lua/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-matlab/pom.xml b/pmd-matlab/pom.xml index 2cece277f7..997cd9179c 100644 --- a/pmd-matlab/pom.xml +++ b/pmd-matlab/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-modelica/pom.xml b/pmd-modelica/pom.xml index 2a68dbbd51..c8db88656a 100644 --- a/pmd-modelica/pom.xml +++ b/pmd-modelica/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-objectivec/pom.xml b/pmd-objectivec/pom.xml index c8b75bb765..015222667c 100644 --- a/pmd-objectivec/pom.xml +++ b/pmd-objectivec/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-perl/pom.xml b/pmd-perl/pom.xml index 8bb50a572d..3a7b91adcc 100644 --- a/pmd-perl/pom.xml +++ b/pmd-perl/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-php/pom.xml b/pmd-php/pom.xml index 6ba5c6d9dc..928d7d78c5 100644 --- a/pmd-php/pom.xml +++ b/pmd-php/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-plsql/pom.xml b/pmd-plsql/pom.xml index 0d427df186..c694ce4fca 100644 --- a/pmd-plsql/pom.xml +++ b/pmd-plsql/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-python/pom.xml b/pmd-python/pom.xml index 11975a4348..ca86db7ca6 100644 --- a/pmd-python/pom.xml +++ b/pmd-python/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-ruby/pom.xml b/pmd-ruby/pom.xml index 41684ffbe7..2c953e41f5 100644 --- a/pmd-ruby/pom.xml +++ b/pmd-ruby/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-scala-modules/pmd-scala-common/pom.xml b/pmd-scala-modules/pmd-scala-common/pom.xml index e220e39d7a..81159650ef 100644 --- a/pmd-scala-modules/pmd-scala-common/pom.xml +++ b/pmd-scala-modules/pmd-scala-common/pom.xml @@ -8,7 +8,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../../pom.xml diff --git a/pmd-scala-modules/pmd-scala_2.12/pom.xml b/pmd-scala-modules/pmd-scala_2.12/pom.xml index f18e317508..ed15aa35f8 100644 --- a/pmd-scala-modules/pmd-scala_2.12/pom.xml +++ b/pmd-scala-modules/pmd-scala_2.12/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd-scala-common - 7.7.0 + 7.8.0-SNAPSHOT ../pmd-scala-common/pom.xml diff --git a/pmd-scala-modules/pmd-scala_2.13/pom.xml b/pmd-scala-modules/pmd-scala_2.13/pom.xml index c72f6c3a8e..31bdc20be3 100644 --- a/pmd-scala-modules/pmd-scala_2.13/pom.xml +++ b/pmd-scala-modules/pmd-scala_2.13/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd-scala-common - 7.7.0 + 7.8.0-SNAPSHOT ../pmd-scala-common/pom.xml diff --git a/pmd-swift/pom.xml b/pmd-swift/pom.xml index 9f3e7cfb0f..78c80b613c 100644 --- a/pmd-swift/pom.xml +++ b/pmd-swift/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-test-schema/pom.xml b/pmd-test-schema/pom.xml index eba0a7ae73..ad89145dcf 100644 --- a/pmd-test-schema/pom.xml +++ b/pmd-test-schema/pom.xml @@ -11,7 +11,7 @@ pmd net.sourceforge.pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-test/pom.xml b/pmd-test/pom.xml index 626b390eaa..a4fbf656eb 100644 --- a/pmd-test/pom.xml +++ b/pmd-test/pom.xml @@ -8,7 +8,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-tsql/pom.xml b/pmd-tsql/pom.xml index 0ca382140f..8094d1662d 100644 --- a/pmd-tsql/pom.xml +++ b/pmd-tsql/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-velocity/pom.xml b/pmd-velocity/pom.xml index 371a275b88..485ee45b6c 100644 --- a/pmd-velocity/pom.xml +++ b/pmd-velocity/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-visualforce/pom.xml b/pmd-visualforce/pom.xml index 19548ea836..49da6f0858 100644 --- a/pmd-visualforce/pom.xml +++ b/pmd-visualforce/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pmd-xml/pom.xml b/pmd-xml/pom.xml index 8b91ba5ca1..7b74978ba4 100644 --- a/pmd-xml/pom.xml +++ b/pmd-xml/pom.xml @@ -7,7 +7,7 @@ net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT ../pom.xml diff --git a/pom.xml b/pom.xml index 81f600916c..c0ca32d41a 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 net.sourceforge.pmd pmd - 7.7.0 + 7.8.0-SNAPSHOT pom PMD @@ -62,7 +62,7 @@ scm:git:git://github.com/pmd/pmd.git scm:git:ssh://git@github.com/pmd/pmd.git https://github.com/pmd/pmd - pmd_releases/7.7.0 + HEAD From 74ec6f45eea903972ec7717642b65e24efdc71ed Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 25 Oct 2024 10:35:02 +0200 Subject: [PATCH 48/52] [doc] Fix release notes for 7.7.0 Old rule name was actually DefaultLabelNotLastInSwitchStmt --- docs/pages/release_notes_old.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/pages/release_notes_old.md b/docs/pages/release_notes_old.md index e55197097a..74a1cfcd25 100644 --- a/docs/pages/release_notes_old.md +++ b/docs/pages/release_notes_old.md @@ -54,7 +54,7 @@ See [PR #5040](https://github.com/pmd/pmd/pull/5040) for details. * [`UnitTestShouldUseTestAnnotation`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestshouldusetestannotation) (Java Best Practices) has been renamed from `JUnit4TestShouldUseTestAnnotation`. * Several rules about switch statements and switch expression have been renamed, as they apply both to Switch Statements and to Switch Expressions: - * [`DefaultLabelNotLastInSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#defaultlabelnotlastinswitch) (Java Best Practices) has been renamed from `DefaultLabelNotLastInSwitch`. + * [`DefaultLabelNotLastInSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#defaultlabelnotlastinswitch) (Java Best Practices) has been renamed from `DefaultLabelNotLastInSwitchStmt`. * [`NonCaseLabelInSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_errorprone.html#noncaselabelinswitch) (Java Error Prone) has been renamed from `NonCaseLabelInSwitchStatement`. * [`TooFewBranchesForSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_performance.html#toofewbranchesforswitch) (Java Performance) has been renamed from `TooFewBranchesForASwitchStatement`. * [`NonExhaustiveSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#nonexhaustiveswitch) (Java Best Practices) has been renamed from `SwitchStmtsShouldHaveDefault`. @@ -91,7 +91,7 @@ The old rule names still work but are deprecated. * The old rule name `JUnitAssertionsShouldIncludeMessage` has been deprecated. Use the new name [`UnitTestAssertionsShouldIncludeMessage`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestassertionsshouldincludemessage) instead. * The old rule name `JUnitTestContainsTooManyAsserts` has been deprecated. Use the new name [`UnitTestContainsTooManyAsserts`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestcontainstoomanyasserts) instead. * The old rule name `JUnitTestsShouldIncludeAssert` has been deprecated. Use the new name [`UnitTestShouldIncludeAssert`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#unittestshouldincludeassert) instead. - * The old rule name `DefaultLabelNotLastInSwitch` has been deprecated. Use the new name [`DefaultLabelNotLastInSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#defaultlabelnotlastinswitch) instead. + * The old rule name `DefaultLabelNotLastInSwitchStmt` has been deprecated. Use the new name [`DefaultLabelNotLastInSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#defaultlabelnotlastinswitch) instead. * The old rule name `SwitchStmtsShouldHaveDefault` has been deprecated. USe the new name [`NonExhaustiveSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_bestpractices.html#nonexhaustiveswitch) instead. * java-errorprone * The old rule name `NonCaseLabelInSwitchStatement` has been deprecated. Use the new name [`NonCaseLabelInSwitch`](https://docs.pmd-code.org/pmd-doc-7.7.0/pmd_rules_java_errorprone.html#noncaselabelinswitch) instead. From 3f697aff35cf7ddd1ce53df47d3e3e9eb5ebb87b Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 25 Oct 2024 18:07:16 +0200 Subject: [PATCH 49/52] [ant] Formatter: avoid reflective access to determine console encoding - for java 17+, there is public API to get the console encoding -> no problem - for older java versions, try to use system property sun.jnu.encoding if it exists - only then use the fall-backs with illegal reflective access to private fields/methods on java.io.Console - Also avoid using reflection utils from apache commons, instead use reflection directly. The illegal access warnings are then properly reported against our class net.sourceforge.pmd.ant.Formatter. Fixes #1860 --- .../net/sourceforge/pmd/ant/Formatter.java | 74 ++++++++++++------- .../java/net/sourceforge/pmd/dist/AntIT.java | 8 +- 2 files changed, 52 insertions(+), 30 deletions(-) diff --git a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java index f6ec0a9518..159f19d7e1 100644 --- a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java +++ b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java @@ -11,6 +11,7 @@ import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; +import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.nio.charset.Charset; @@ -21,8 +22,6 @@ import java.util.List; import java.util.Properties; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.reflect.FieldUtils; -import org.apache.commons.lang3.reflect.MethodUtils; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.types.Parameter; @@ -200,10 +199,12 @@ public class Formatter { if (console != null) { // Since Java 22, this returns a console even for redirected streams. // In that case, we need to check Console.isTerminal() + // https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/io/Console.html#isTerminal() // See: JLine As The Default Console Provider (JDK-8308591) try { - Boolean isTerminal = (Boolean) MethodUtils.invokeMethod(console, "isTerminal"); - if (!isTerminal) { + Method method = Console.class.getMethod("isTerminal"); + Object isTerminal = method.invoke(console); + if (isTerminal instanceof Boolean && !(Boolean) isTerminal) { // stop here, we don't have an interactive console. return null; } @@ -211,39 +212,58 @@ public class Formatter { // fall-through - we use a Java Runtime < 22. } + // Maybe this is Java17+? Then there will be a public method charset() + // https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/Console.html#charset() try { - Object res = FieldUtils.readDeclaredField(console, "cs", true); - if (res instanceof Charset) { - return ((Charset) res).name(); + Method method = Console.class.getMethod("charset"); + Object charset = method.invoke(console); + if (charset instanceof Charset) { + return ((Charset) charset).name(); + } + } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException ignored) { + // fall-through + } + + { + // try to use the system property "sun.jnu.encoding", which is the platform encoding. + // this property is not specified and might not always be available, but it is for + // openjdk 11: https://github.com/openjdk/jdk11u/blob/cee8535a9d3de8558b4b5028d68e397e508bef71/src/java.base/share/native/libjava/System.c#L384 + // if it exists, we use it - this avoids illegal reflective access below. + String jnuEncoding = System.getProperty("sun.jnu.encoding"); + if (jnuEncoding != null) { + return jnuEncoding; + } + } + + // the following parts are accessing private/protected fields via reflection + // this should work with Java 8 and 11. With Java 11, you'll see warnings abouts + // illegal reflective access, see #1860. However, the access still works. + + // Fall-Back 1: private field "cs" in java.io.Console + try { + Field field = Console.class.getDeclaredField("cs"); + field.setAccessible(true); + Object csField = field.get(console); + if (csField instanceof Charset) { + return ((Charset) csField).name(); } } catch (IllegalArgumentException | ReflectiveOperationException ignored) { // fall-through } - // Maybe this is Java17+? Then there will be - // https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/Console.html#charset() - // instead of the field "cs". + // Fall-Back 2: private native method "encoding()" in java.io.Console try { - Method charsetMethod = Console.class.getDeclaredMethod("charset"); - Charset charset = (Charset) charsetMethod.invoke(console); - return charset.name(); - } catch (IllegalArgumentException | ReflectiveOperationException ignored) { + Method method = Console.class.getDeclaredMethod("encoding"); + method.setAccessible(true); + Object encoding = method.invoke(console); + if (encoding instanceof String) { + return (String) encoding; + } + } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException ignored) { // fall-through } - return getNativeConsoleEncoding(); - } - return null; - } - - private static String getNativeConsoleEncoding() { - try { - Object res = MethodUtils.invokeStaticMethod(Console.class, "encoding"); - if (res instanceof String) { - return (String) res; - } - } catch (IllegalArgumentException | ReflectiveOperationException ignored) { - // fall-through } + // we couldn't determine the correct platform console encoding return null; } diff --git a/pmd-dist/src/test/java/net/sourceforge/pmd/dist/AntIT.java b/pmd-dist/src/test/java/net/sourceforge/pmd/dist/AntIT.java index d52070662f..6a0402d8a5 100644 --- a/pmd-dist/src/test/java/net/sourceforge/pmd/dist/AntIT.java +++ b/pmd-dist/src/test/java/net/sourceforge/pmd/dist/AntIT.java @@ -5,6 +5,8 @@ package net.sourceforge.pmd.dist; import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.containsStringIgnoringCase; +import static org.hamcrest.Matchers.not; import java.io.File; import java.io.IOException; @@ -40,9 +42,9 @@ class AntIT extends AbstractBinaryDistributionTest { ExecutionResult result = runAnt(antBasepath, pmdHome, antTestProjectFolder); result.assertExitCode(0) - .assertStdOut(containsString("BUILD SUCCESSFUL")); - // the no package rule - result.assertExitCode(0) + .assertStdOut(containsString("BUILD SUCCESSFUL")) + .assertStdOut(not(containsStringIgnoringCase("Illegal reflective access"))) // #1860 + // the no package rule .assertStdOut(containsString("NoPackage")); } From 9c098b253106a980e5eea10651561ef7b82c4af8 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sun, 27 Oct 2024 15:20:28 +0100 Subject: [PATCH 50/52] Bump pmd from 7.5.0 to 7.7.0 (#5285) * Bump pmd from 7.5.0 to 7.7.0 * Bump build-tools from 27 to 28-SNAPSHOT Needed to remove deprecation warnings about old rule names --- pom.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index c0ca32d41a..e429008001 100644 --- a/pom.xml +++ b/pom.xml @@ -115,7 +115,7 @@ -Xmx512m -Dfile.encoding=${project.build.sourceEncoding} ${extraArgLine} - 27 + 28-SNAPSHOT 7.2.0 @@ -569,22 +569,22 @@ net.sourceforge.pmd pmd-core - 7.5.0 + 7.7.0 net.sourceforge.pmd pmd-java - 7.5.0 + 7.7.0 net.sourceforge.pmd pmd-jsp - 7.5.0 + 7.7.0 net.sourceforge.pmd pmd-javascript - 7.5.0 + 7.7.0 From d68d6c57efa0d9e8d9613955b27a56662f6629cc Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sun, 27 Oct 2024 15:53:00 +0100 Subject: [PATCH 51/52] Bump asm from 9.7 to 9.7.1 This enables support for Java 24 Refs #5154 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index e429008001..d91edae2cc 100644 --- a/pom.xml +++ b/pom.xml @@ -592,11 +592,11 @@ pmd-build-tools-config ${pmd.build-tools.version} - + org.ow2.asm asm - 9.7 + 9.7.1 @@ -828,7 +828,7 @@ org.ow2.asm asm - 9.7 + 9.7.1 org.pcollections From c81cd1d5203114ee42c781ce243ad044ff242944 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 03:31:36 +0000 Subject: [PATCH 52/52] Bump org.apache.maven.plugins:maven-assembly-plugin from 3.6.0 to 3.7.1 Bumps [org.apache.maven.plugins:maven-assembly-plugin](https://github.com/apache/maven-assembly-plugin) from 3.6.0 to 3.7.1. - [Release notes](https://github.com/apache/maven-assembly-plugin/releases) - [Commits](https://github.com/apache/maven-assembly-plugin/compare/maven-assembly-plugin-3.6.0...maven-assembly-plugin-3.7.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-assembly-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d91edae2cc..d09220f92b 100644 --- a/pom.xml +++ b/pom.xml @@ -179,7 +179,7 @@ org.apache.maven.plugins maven-assembly-plugin - 3.6.0 + 3.7.1 org.apache.maven.plugins