0

I'm using lombok-1.18.18 and google error_prone_core-2.11.0 in my spring boot application. When using @EqualsAndHashCode and @NoArgsConstructor from Lombok getting build error in Google Errorprone. Error telling is telling something like below:

For @EqualsAndHashCode:

error: [MissingBraces] The Google Java Style Guide requires braces to be u
sed with if, else, for, do and while statements, even when the body is empty or contains only a single statement.
@EqualsAndHashCode(onlyExplicitlyIncluded = true)

For @NoArgsConstructor (there is constructor like public MyEntity(int someparam)):

error: [UngroupedOverloads] Overloads should be grouped toge
ther, even when modifiers such as static or private differ between the methods; found ungrouped constructor overloads on line(s): 36
@NoArgsConstructor
^
    (see https://errorprone.info/bugpattern/UngroupedOverloads)
  Did you mean '@Setter'?

My Entity class looks like this:

@Entity
@Getter
@Setter
@NoArgsConstructor
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@ToString(onlyExplicitlyIncluded = true)
@Table(name = "my_entity")
public class MyEntity implements Serializable {

Lombok Config:

lombok.copyableAnnotations += org.springframework.beans.factory.annotation.Qualifier
lombok.copyableAnnotations += org.springframework.context.annotation.Lazy
lombok.copyableAnnotations += org.springframework.beans.factory.annotation.Value
lombok.addLombokGeneratedAnnotation = true
mmuzahid
  • 2,252
  • 23
  • 42
  • Does this answer your question? [How do I make error-prone ignore my generated source code?](https://stackoverflow.com/questions/39561334/how-do-i-make-error-prone-ignore-my-generated-source-code) – David Conrad Mar 07 '22 at 17:52
  • You likely also need a `lombok.config` file in your project with "lombok.addLombokGeneratedAnnotation = true" in it. – David Conrad Mar 07 '22 at 17:54
  • @DavidConrad added `lombok.addLombokGeneratedAnnotation = true` in lombok config but still getting error for lombok annotation like [MissingBraces] – mmuzahid Mar 09 '22 at 04:57
  • And did you turn on the flag for Errorprone to tell it to disable warnings in generated code? – David Conrad Mar 09 '22 at 17:08
  • @DavidConrad I set in gradle config `options.errorprone { disableWarningsInGeneratedCode = true` ....}` – mmuzahid Mar 10 '22 at 08:39
  • Sorry, it seems that flag only works for warnings, and for errors you must use `-XepExcludedPaths`. See: https://stackoverflow.com/a/55335407/636009 and https://stackoverflow.com/a/55777408/636009 – David Conrad Mar 10 '22 at 15:14

0 Answers0