How to exclude only generated methods from sonarqube analysis?

I would like to exclude generated methods like “equals”, “hashCode” and “toString” from Sonarqube analysis, but I can’t exclude the whole entity class since I’m using rich entities with behavior (DDD).

I guess this is a common use case, but I can find only documentaiton about “class exclusion” or “line exclusion”, not “method exclusion”, how can I deal with this common use case in Sonarqube/Sonarlint ?

Ideally, Sonarqube would allow to ignore annotated methods with @lombok.Generated or javax.annotation.processing.Generated("intelliJ");

For example, I don’t want to fix/alter this awful generated code, I just want it to be ignored :


Sonarqube rules triggered :

But I want this method in the same class to trigger warnings if necessary :


The only option is to mark off the generated methods and exclude what’s between the markers.


1 Like

Hi Ann, ok thank you I missed this “ignoring blocks” section in the doc, I guess it’s new in the latest LTS doc.