Repository navigation
[java] New rule: ProtectedMemberInFinalClass - #6964
Conversation
970bebd to
9fcc56c
Compare
|
Compared to main: (comment created at 2026-08-19 19:21:06+00:00 for bf7ce80) |
|
I wonder if this is not already subsumed by unnecessarymodifier? |
|
@oowekyala currently not; should we merge it into that one? The semantic is slightly different -- |
UncleOwen
left a comment
There was a problem hiding this comment.
Please also add something to the "new rules" section of the release notes.
4aaecaa to
62119c1
Compare
UncleOwen
left a comment
There was a problem hiding this comment.
Thanks.
And I think this is sufficiently different from UnnecessaryModifier to keep as its own rule.
|
@zbynek @UncleOwen Should we move this new rule into the design category? The original issue suggested that. |
|
Now that you mention it... yes. This isn't a style issue. |
| Do not use protected fields in final classes since they cannot be subclassed. | ||
| Clarify your intent by using private or package access modifiers instead. | ||
|
|
||
| **Deprecated:** This rule is deprecated since PMD 7.27.0 and will be removed with PMD 8.0.0. This rule has been replaced by {% rule ProtectedMemberInFinalField %}, which covers all class members. |
There was a problem hiding this comment.
Describe the PR
Two existing rules for protected members in final classes are merged to one. The new rule also covers nested type declarations where the outer one is final and the inner one is protected.
Related issues
Ready?
./mvnw clean verifypasses (checked automatically by github actions)