hibernate-orm icon indicating copy to clipboard operation
hibernate-orm copied to clipboard

HHH-15846 Option to add @SuppressFBWarnings annotation on generated code

Open NicklasWallgren opened this issue 1 year ago • 7 comments

Lombok has an option to add @SuppressFBWarnings to generated code via lombok.extern.findbugs.addSuppressFBWarnings.

It would be really helpful if the hibernate gradle/maven enhance plugins would provide a similar option.

We're currently struggling with warnings related to hibernate generated code in our entities, in SpotBugs.

NP | Non-null field $_hibernate_attributeInterceptor is not initialized by new <entity>
NP | Non-null field $_hibernate_entityEntryHolder is not initialized by new <entity>
NP | Non-null field $_hibernate_nextManagedEntity is not initialized by new <entity>
NP | Non-null field $_hibernate_previousManagedEntity is not initialized by new <entity>
NP | Non-null field $_hibernate_tracker is not initialized by new <entity>

Discussion on GitHub Enhance plugin - Option to add @SuppressFBWarnings annotation · Discussion #5668 · hibernate/hibernate-orm

NicklasWallgren avatar Dec 17 '22 12:12 NicklasWallgren

Thanks for your pull request!

This pull request appears to follow the contribution rules.

› This message was automatically generated.

@gavinking Are you able to review this PR, or any of the other contributors? 🙂 Thanks

NicklasWallgren avatar Dec 23 '22 14:12 NicklasWallgren

@gavinking Are you able to review this PR, or any of the other contributors? 🙂 Thanks

Hi, I don't know what @SuppressFBWarnings is, nor why you want this, and neither the JIRA issue nor the discussion explain it...

gavinking avatar Dec 23 '22 15:12 gavinking

@gavinking Are you able to review this PR, or any of the other contributors? 🙂 Thanks

Hi, I don't know what @SuppressFBWarnings is, nor why you want this, and neither the JIRA issue nor the discussion explain it...

Ah sorry, I got you mixed up with @Sanne. The annotation is used to suppress any warnings found by FindBugs or SpotBugs.

NicklasWallgren avatar Dec 23 '22 15:12 NicklasWallgren

@NicklasWallgren Can you rebase this on main? And I will take a look.

sebersole avatar Jun 08 '23 12:06 sebersole

Also, the discussion mentioned @Generated but I do not see that handled here. Is that a different PR or just not added?

sebersole avatar Jun 08 '23 12:06 sebersole

@NicklasWallgren Could you explain how an annotation you are adding into Hibernate here in this PR somehow affects those other libraries? How do FindBugs, etc know to look for this annotation?

Could we not just leverage java.lang.SuppressWarnings for this?

sebersole avatar Aug 30 '23 11:08 sebersole