Skip to content
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] Fixes 3859: Exclude junit5 test methods from the commentDefaultAccessModifierRule #4137

Merged

Conversation

lfalcantar
Copy link
Contributor

@lfalcantar lfalcantar commented Sep 28, 2022

Describe the PR

There was a conflict between the CommentDefaultAccessModifier and the JUnit5TestShouldBePackagePrivate rule. while the JUnit5TestShouldBePackagePrivate rule passed, the CommentDefaultAccessModifier complained about the lack of a comment on the method encapsulation generating a false alert.

example @org.junit.jupiter.api.Test void MissingCommentMethod {}", missing " /* default */ but not required in junit5.

The changes will exclude methods with junit5 @test or @ParameterizedTest annotation for the commentDefaultAccessModifierRule.

Related issues

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

…tAccessModifierRule

There was a conflict between the CommentDefaultAccessModifier and the JUnit5TestShouldBePackagePrivate rule. while the JUnit5TestShouldBePackagePrivate rule passed, the CommentDefaultAccessModifier complained about the lack of a comment on the method encapsulation generating a false alert.

example "@org.junit.jupiter.api.Test void MissingCommentMethod {}", missing " /* default */" but not required in junit5.

The changes will exclude methods with junit5 @test or @ParameterizedTest annotation for the commentDefaultAccessModifierRule.
Copy link
Member

@adangel adangel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

The solution can probably be simpler: The rule supports the property "ignoredAnnotations", so all we need to do is, to add org.junit.jupiter.api.Test (and others) to the method defaultSuppressionAnnotations().

I'll give it a try....

@adangel adangel added this to the 6.50.0 milestone Sep 29, 2022
@pmd-test
Copy link

1 Message
📖 Compared to master:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 7125 violations, 2 errors and 6 configuration errors.
Full report

Generated by 🚫 Danger

@adangel adangel merged commit dbe2881 into pmd:master Sep 29, 2022
adangel added a commit to adangel/pmd that referenced this pull request Sep 29, 2022
…default-access-modifier

[java] Fixes 3859: Exclude junit5 test methods from the commentDefaultAccessModifierRule pmd#4137
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[java] CommentDefaultAccessModifier is triggered in JUnit5 test class
3 participants