Skip to content

False positives for Lombok's @Data annotation #557

@ksiczek

Description

@ksiczek

Describe the bug

  • I have verified that the issue is reproducible against the latest version
    of the project.
  • I have searched through existing issues to verify that this issue is not
    already known.

Minimal Reproducible Example

Given below class

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

@Data
public class ErrorProneTestObject {

    @JsonProperty("event")
    private String event;

}

we get unclear recommendations saying that we might replace @Data with @Data (see Logs section). It seems it happens only for Lombok @Data, or @Setter:

@Setter
public class ErrorProneTestObject {

    @JsonProperty("event")
    private String event;

    public String getEvent() {
        return event;
    }

} 
Logs
.../ErrorProneTestObject.java:6: Note: [CanonicalAnnotationSyntax] Omit redundant syntax from annotation declarations
@Data
^
    (see https://error-prone.picnic.tech/bugpatterns/CanonicalAnnotationSyntax)
  Did you mean '@Data'?

I tried several different combinations of the annotations and configurations and it seems that:

  • it always happens if you use the ones I specified above
  • it stops happening if I remove one of them
  • it also stops happening if I remove JsonProperty's parameter

Expected behavior

I'm pretty sure that the error message does not help much so it is either a bug in the analysis or in the message. Does it sound familiar to you guys?

Setup

  • MacOS Ventura
  • openjdk version "19.0.2" 2023-01-17
  • Error Prone version 2.18.0
  • Error Prone Support version 0.8.0
  • EDIT: I also have disableWarningsInGeneratedCode = true in the configuration

Additional context

I just started using error-prone and it might be a good opportunity for me to see how custom rules work. If you consider reported behavior a bug I think I could dive deeper into it ☺️

Metadata

Metadata

Labels

bugSomething isn't workinghelp wantedExtra attention is needed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions