Error-prone: lombok.Generated annotation is ignored

Created on 14 Oct 2020  路  3Comments  路  Source: google/error-prone

Description of the problem / feature request:

Enabling Lombok's @Generated annotation via lombok.addLombokGeneratedAnnotation = true does not reduce the number of reported issues.

Feature requests: what underlying problem are you trying to solve with this feature?

Error Prone ignores the lombok.Generated annotation. Unlike the javax.annotation.processing.Generated annotation this one has @Retention(CLASS) instead of SOURCE.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Adding a few Lombok annotations is usually enough to trigger a violation. There are already some examples available here:
https://github.com/google/error-prone/issues/1700
https://github.com/google/error-prone/issues/1482
https://github.com/google/error-prone/issues/1481

What version of Error Prone are you using?

2.4.0

Have you found anything relevant by searching the web?

No

Most helpful comment

It would actually be great if ErrorProne accepted any annotation named Generated whichever the package.

The fact that javax.annotation.processing.Generated has SOURCE retention is a real problem, leading to many code generators to come with their own Generated annotation with CLASS retention (like the now-defunct javax.annotation.Generated): Lombok, Immutables, someone asked it for jOOQ, someone else for MapStruct, and I'm sure there are (many) others.

All 3 comments

It would actually be great if ErrorProne accepted any annotation named Generated whichever the package.

The fact that javax.annotation.processing.Generated has SOURCE retention is a real problem, leading to many code generators to come with their own Generated annotation with CLASS retention (like the now-defunct javax.annotation.Generated): Lombok, Immutables, someone asked it for jOOQ, someone else for MapStruct, and I'm sure there are (many) others.

1984 is a related bug about org.immutables (which I think is supposed to try to use the javax.* annotations if they're available, but doesn't seem to be doing that).

It would actually be great if ErrorProne accepted any annotation named Generated whichever the package.

Done: https://github.com/google/error-prone/commit/4d6a0cce2d2ccc6a945352c2ba38201f753994bd

That doesn't solve all of our problems with lombok (see https://github.com/google/error-prone/issues/1250#issuecomment-763097162 for current thoughts on that), but it should be enough to recognize lombok's annotation in -XepDisableWarningsInGeneratedCode

Was this page helpful?
0 / 5 - 0 ratings