From c071143880ce6c98e9963f863b1330217607affa Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 6 Oct 2023 18:58:15 +0200 Subject: [PATCH] [java] CommentDefaultAccessModifier: Fix ParameterizedTest annotation Fixes #4645 --- docs/pages/release_notes.md | 3 +++ .../CommentDefaultAccessModifierRule.java | 14 +++++++------- .../codestyle/xml/CommentDefaultAccessModifier.xml | 6 +++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index f6853072df..201bc84b47 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -42,6 +42,8 @@ The remaining section describes the complete release notes for 7.0.0. #### New and Noteworthy #### Fixed issues +* java-codestyle + * [#4645](https://github.com/pmd/pmd/issues/4645): \[java] CommentDefaultAccessModifier - False Positive with JUnit5's ParameterizedTest #### API Changes @@ -558,6 +560,7 @@ Language specific fixes: * [#4511](https://github.com/pmd/pmd/issues/4511): \[java] LocalVariableCouldBeFinal shouldn't report unused variables * [#4512](https://github.com/pmd/pmd/issues/4512): \[java] MethodArgumentCouldBeFinal shouldn't report unused parameters * [#4557](https://github.com/pmd/pmd/issues/4557): \[java] UnnecessaryImport FP with static imports of overloaded methods + * [#4645](https://github.com/pmd/pmd/issues/4645): \[java] CommentDefaultAccessModifier - False Positive with JUnit5's ParameterizedTest * java-design * [#1014](https://github.com/pmd/pmd/issues/1014): \[java] LawOfDemeter: False positive with lambda expression * [#1605](https://github.com/pmd/pmd/issues/1605): \[java] LawOfDemeter: False positive for standard UTF-8 charset name diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/CommentDefaultAccessModifierRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/CommentDefaultAccessModifierRule.java index 5d5892bc43..23506062fe 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/CommentDefaultAccessModifierRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/CommentDefaultAccessModifierRule.java @@ -52,16 +52,16 @@ public class CommentDefaultAccessModifierRule extends AbstractJavaRulechainRule "com.google.common.annotations.VisibleForTesting", "android.support.annotation.VisibleForTesting", "co.elastic.clients.util.VisibleForTesting", - "org.junit.jupiter.api.Test", - "org.junit.jupiter.api.extension.RegisterExtension", - "org.junit.jupiter.api.ParameterizedTest", + "org.junit.jupiter.api.AfterAll", + "org.junit.jupiter.api.AfterEach", + "org.junit.jupiter.api.BeforeAll", + "org.junit.jupiter.api.BeforeEach", "org.junit.jupiter.api.RepeatedTest", + "org.junit.jupiter.api.Test", "org.junit.jupiter.api.TestFactory", "org.junit.jupiter.api.TestTemplate", - "org.junit.jupiter.api.BeforeEach", - "org.junit.jupiter.api.BeforeAll", - "org.junit.jupiter.api.AfterEach", - "org.junit.jupiter.api.AfterAll", + "org.junit.jupiter.api.extension.RegisterExtension", + "org.junit.jupiter.params.ParameterizedTest", "org.testng.annotations.Test", "org.testng.annotations.AfterClass", "org.testng.annotations.AfterGroups", diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/CommentDefaultAccessModifier.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/CommentDefaultAccessModifier.xml index 6a42aa94f3..bfa7111222 100755 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/CommentDefaultAccessModifier.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/CommentDefaultAccessModifier.xml @@ -454,16 +454,16 @@ public enum MyEnum { - #3859 #4273 [java] CommentDefaultAccessModifier is triggered in JUnit5 method and it was conflicting with rule JUnit5TestShouldBePackagePrivate + #3859 #4273 #4645 [java] CommentDefaultAccessModifier is triggered in JUnit5 method and it was conflicting with rule JUnit5TestShouldBePackagePrivate 0