Sonarqube bad coverage because of lombok @Data

Martin Choraine picture Martin Choraine · Aug 8, 2017 · Viewed 11.2k times · Source

I use jacoco for coverage report. When I look at the jacoco report, coverage seems to be good. But in Sonarqube, the coverage is low because it says that @Dataannotation from lombok is not cover by test.

Compiled classes is mark as @Generated but it's not ignored by Sonar.

How can I make exclude @Data of the analysis ?

Answer

Vlad Schnakovszki picture Vlad Schnakovszki · Mar 25, 2020

Godin's answer is correct but there is now a way to add that annotation automatically.

In order to do this you can create a lombok.config file in the root of your project and add this line in it:

lombok.addLombokGeneratedAnnotation = true

Full details here. As detailed in the documentation:

Lombok can be configured to add @lombok.Generated annotations to all generated nodes where possible; useful for JaCoCo (which has built in support), or other style checkers and code coverage tools: lombok.addLombokGeneratedAnnotation = true