You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[java] Merge AccessorClassGeneration and AccessorMethodGeneration #2892
Both rules basically do the same check, ie they check for private members being accessed from outside the class they're defined in. The difference, is that AccessorClassGeneration only checks for private constructors, while the other rule checks for other kinds of members (fields and methods).
I think separating those is not useful, as the fix in both cases is the same: make the member non-private. The fact that for some kinds of members an accessor class is generated, and for the others, an accessor method, is a technicality that does not affect how a user would use those rules. It would be described in the documentation though.
Describe the solution you'd like Merge both rules into a new PrivateMemberAccess rule.
Describe alternatives you've considered
None
Additional context In PMD 7 the way I rewrote those rules is identical, and AccessorClassGeneration uses the implementation in AccessorMethodGeneration. Having a single class would be nice. See AccessorClassGeneration
It would also be nice to report the violation on the field/method/constructor being caught and not the usage, as there might be several usages, and it's easier to fix it this way. This is done in the rewrite for pmd 7.
changed the title [-]Merge AccessorClassGeneration and AccessorMethodGeneration[/-][+][java] Merge AccessorClassGeneration and AccessorMethodGeneration[/+]on Nov 2, 2020
Note: These rules are only valid until java 10. After that, with java 11, there is support for JEP 181: Nest-Based Access Control. Then accessor classes/methods are not generated anymore.
This info is unfortunately not mentioned in the rule description, but it should be.
Activity
[-]Merge AccessorClassGeneration and AccessorMethodGeneration[/-][+][java] Merge AccessorClassGeneration and AccessorMethodGeneration[/+]adangel commentedon Nov 23, 2020
Note: These rules are only valid until java 10. After that, with java 11, there is support for JEP 181: Nest-Based Access Control. Then accessor classes/methods are not generated anymore.
This info is unfortunately not mentioned in the rule description, but it should be.
Otherwise 👍 for merging.