Check to enforce accessor usage on nested record classes
- Dominant language
- Java
- Stars
- 7.2k
- Forks
- 820
- Avg merge
- 5h 9m
- Merged PRs (30d)
- 50
Description
Hey there,
in some places, we use nested records to e.g. return multiple values from a method, or to encapsulate them for passing them as single argument instead of multiples. Most of those records are private nested classes as they are in almost all cases very specific.
The problem is, that Java allows to use the fields of nested records directly e.g `r.name` instead of the accessor `r.name()`.
I have not found a check for this case, only [RecordAccessorInCompactConstructor](https://errorprone.info/bugpattern/RecordAccessorInCompactConstructor) which ironically does kind of the opposite.
Depending on how common our use case is in the outside world, I wonder if it would make sense to have such a check in errorprone directly.
Currently we are considering to build that check for our internal plugin, but if there is interest in having it as a core check we could contribute it.
Contributor guide
Research direction
Start with the linked RecordAccessorInCompactConstructor check and compare it with the nested-record use cases described here. First establish whether this belongs in Error Prone core or an internal plugin, then define the scope of checking direct field access versus accessors and what would demonstrate that the check is complete.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100