[java] False positive for UnusedPrivateField referenced by @FieldSource#6686
Conversation
|
Compared to main: (comment created at 2026-05-18 18:47:52+00:00 for bbfa70c) |
UncleOwen
left a comment
There was a problem hiding this comment.
Nice catch that this is basically already implemented!
I've left a few suggestions. Apart from those, I like it!
Co-authored-by: Sören Glimm <git@uncleowen.de>
UncleOwen
left a comment
There was a problem hiding this comment.
Remember to add the changelog entry :)
| * java-bestpractices | ||
| * [#3212](https://github.com/pmd/pmd/issues/3212): \[java] Enhance UseStandardCharsets to flag some constructors of IO-related classes | ||
| * [#3777](https://github.com/pmd/pmd/issues/3777): \[java] New rule: AssertStatementInTest | ||
| * [#6606](https://github.com/pmd/pmd/issues/6606): \[java] UnusedPrivateField: False positive on JUnit Jupiter `@FieldSource` |
There was a problem hiding this comment.
FYI:
Another way to prevent Github from notifying a user that is called "FieldSource" is using html comments, like this:
@<!-- -->FieldSource
We often have this when we reference an annotation in issue/pull request titles
There was a problem hiding this comment.
Is that preferred over the backticks? I think having it rendered as code is easier to read.
(I just noticed it's also highlighting the username in the commit message, sorry about that.)
Describe the PR
Reuses code that prevents private methods to be flagged as unused if they are referenced by
@MethodSourceto do the same for fields referenced by@FieldSource.Related issues
Ready?
./mvnw clean verifypasses (checked automatically by github actions)