New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[java] CommentDefaultAccessModifier - False Positive with JUnit5's ParameterizedTest #4645
Comments
This is fixed in PMD 7: https://docs.pmd-code.org/latest/pmd_rules_java_codestyle.html#commentdefaultaccessmodifier |
Hi @oowekyala , To clarify:
private static final PropertyDescriptor<List<String>> IGNORED_ANNOTS =
JavaPropertyUtil.ignoredAnnotationsDescriptor(
"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.params.ParameterizedTest" is not there |
You are right, the annotation is wrong, it is in the package The rule CommentDefaultAccessModifier seems to be the only one, that uses the wrong package - other rules, that mention this annotation are correct. When fixing this, also the test case needs to be fixed: Line 462 in 89c7da8
Note: If you don't want to wait for a new PMD release, you can simply configure the rule yourself, see https://docs.pmd-code.org/latest/pmd_userdocs_configuring_rules.html In this special case, you can use: <rule ref="category/java/codestyle.xml/CommentDefaultAccessModifier">
<properties>
<property name="ignoredAnnotations" value="android.support.annotation.VisibleForTesting,co.elastic.clients.util.VisibleForTesting,com.google.common.annotations.VisibleForTesting,org.junit.jupiter.api.AfterAll,org.junit.jupiter.api.AfterEach,org.junit.jupiter.api.BeforeAll,org.junit.jupiter.api.BeforeEach,org.junit.jupiter.params.ParameterizedTest,org.junit.jupiter.api.RepeatedTest,org.junit.jupiter.api.Test,org.junit.jupiter.api.TestFactory,org.junit.jupiter.api.TestTemplate,org.junit.jupiter.api.extension.RegisterExtension,org.testng.annotations.AfterClass,org.testng.annotations.AfterGroups,org.testng.annotations.AfterMethod,org.testng.annotations.AfterSuite,org.testng.annotations.AfterTest,org.testng.annotations.BeforeClass,org.testng.annotations.BeforeGroups,org.testng.annotations.BeforeMethod,org.testng.annotations.BeforeSuite,org.testng.annotations.BeforeTest,org.testng.annotations.Test" />
<property name="regex" value="\/\*\s*(default|package)\s*\*\/" />
<property name="checkTopLevelTypes" value="false" />
</properties>
</rule> |
Affects PMD Version: 6.55.0, 7.0.0-rc4
Rule: CommentDefaultAccessModifier
Description:
Package defined in ignoredAnnotations is not correct.
Should: org.junit.jupiter.params.ParameterizedTest
But: org.junit.jupiter.api.ParameterizedTest
The text was updated successfully, but these errors were encountered: