google / google/error-prone

Spurious "SameNameButDifferent" warning on Lombok code with `@Getter` and `@Builder`

Open
#3,187 3 comments 2 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
7.2k
Forks
820
Avg merge
5h 9m
Merged PRs (30d)
50

Description

For some Lombok code with a `@Getter` annotation, the "SameNameButDifferent" warning is triggered with an error message that seems to suggest it's treating the other types and annotations on the field as if they are field names. (?)

Related to #2982, #3094, but different because it's now a spurious warning instead of an exception.

```
...\src\main\java\com\example\Person.java:13: warning: [SameNameButDifferent] The name `@Getter` refers to [javax.annotation.Nullable, java.lang.SuppressWarnings, lombok.Generated, java.lang.String] within this file. It may be confusing to have the same name refer to multiple types. Consider qualifying them for clarity.
@Getter
^
(see https://errorprone.info/bugpattern/SameNameButDifferent)
```

Versions in play:
* Lombok 1.18.24
* ErrorProne 2.7.1, 2.13.1
* Java 11

[Repro](https://github.com/hakanai/errorprone-lombok-missingsummary) - **NOTE:** This repo was for reproducing a different issue, but it exhibits this issue also. You might want to comment out the MissingSummary line in `build.gradle.kts`, otherwise that causes an outright failure, but you should get the warning about SameNameButDifferent in the output regardless.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.