Skip to content

Check to enforce accessor usage on nested record classes #6048

Description

@dodgex

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 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions