Can we suppress lombok warnings?

895 views
Skip to first unread message

Byungjun You

unread,
Sep 6, 2022, 8:43:57 AM9/6/22
to Project Lombok
My question is "is there any way to suppress lombok warnings by specifying an annotation like @SuppressWarnings()?"

I have configured `lombok.value.flagUsage=warning` to warn any use of `@Value` annotation. The reason why I configured this way is to encourage to use `record` instead of `@Value`.

But some cases it is more appropriate to use @Value than `record`. So in that case I want to suppress lombok warning.

Reinier Zwitserloot

unread,
Sep 6, 2022, 10:04:35 AM9/6/22
to Project Lombok
`@SuppressWarnings` is unspecced. Which means its unfortunately mostly useless - if you make up your own 'keys' for suppression, IDEs warn that the key isn't recognized. This is a frankly idiotic state of affairs, because of the idea of @SW is that only a specific enumerated set of strings are valid in the first place, it would have obviously been designed based on an enum instead. There is a key to suppress unknown SW keys, but now we need to write in the manual something like: "To suppress lomboks warnings on this front, add @SW and add string keys "lombok-flagusage-value" and "unknown-sw-key" for eclipse, or "unknown-this-or-that" for intellij, etc". Clearly not worth it at that point.

We could introduce a lombok-specific suppression annotation, but we don't currently have that. I'm not sure I particularly like creating such a thing, I'd have to think through the utility of such a feature. Letting you emit a 'hey, uh, maybe `record`'? reminder is nice. My main issue is: Lombok's warnings are generally errors (in the sense that an error often stops IDE code gen and such, and that isn't the intent, but it's generally always bad enough that you should just fix it, and not push this to a main branch, ever). Suppressing them is rarely something that makes sense in the first place. In other words, your use case is the only one I can think of. That's not good enough for adding such a feature.

Floris Kraak

unread,
Sep 6, 2022, 1:23:06 PM9/6/22
to project...@googlegroups.com

The SonarLint plugin will emit this warning as well as warnings for a lot of other things Lombok shouldn't care about.

I don't think this should be Lombok's job, people should just install a good quality inspection tool for that.


--
You received this message because you are subscribed to the Google Groups "Project Lombok" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-lombo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/project-lombok/cdeec708-e0e9-4a58-9de1-e414adc2f3c0n%40googlegroups.com.

Thorsten Glaser

unread,
Sep 6, 2022, 3:14:50 PM9/6/22
to Project Lombok
On Tue, 23 Aug 2022, Byungjun You wrote:

> I have configured `lombok.value.flagUsage=warning` to warn any use of
> `@Value` annotation. The reason why I configured this way is to encourage
> to use `record` instead of `@Value`.
>
> But some cases it is more appropriate to use @Value than `record`. So in
> that case I want to suppress lombok warning.

Perhaps put such cases into separate subdirectories then put a
suitable lombok config into just that directory? Does that work?

bye,
//mirabilos
--
Infrastrukturexperte • tarent solutions GmbH
Am Dickobskreuz 10, D-53121 Bonn • http://www.tarent.de/
Telephon +49 228 54881-393 • Fax: +49 228 54881-235
HRB AG Bonn 5168 • USt-ID (VAT): DE122264941
Geschäftsführer: Dr. Stefan Barth, Kai Ebenrett, Boris Esser, Alexander Steeg

****************************************************
/⁀\ The UTF-8 Ribbon
╲ ╱ Campaign against Mit dem tarent-Newsletter nichts mehr verpassen:
 ╳  HTML eMail! Also, https://www.tarent.de/newsletter
╱ ╲ header encryption!
****************************************************
Reply all
Reply to author
Forward
0 new messages