DEV Community

Cover image for Lombok: Fixing SonarQube coverage problem
Mateus Malaquias
Mateus Malaquias

Posted on • Originally published at malaquias.dev

Lombok: Fixing SonarQube coverage problem

Photo by Scott Rodgerson on Unsplash

Here is a Portuguese version.

In my ongoing project, I have a CI/CD flow and one step is responsible to collect the code coverage and validate if I have the minimal value to proceed to another step.

However, even having 84% of code coverage, the SonarQube always returned 30% of the result in the step, because of that the deployment step was never executed.

I spent some time understanding that the problem was in the Lombok annotations, the SonarQube was computing the generated code.

The solution:

It's simple to resolve this issue. I created a file named lombok.config inside the folder java (/../src/main/java/lombok.config) with this:

config.stopBubbling = true
lombok.addLombokGeneratedAnnotation = true
Enter fullscreen mode Exit fullscreen mode

What are these settings for?

The config.stopBubbling informs the Lombok that the folder where the file is the root and the Lombok don't need to search for more parent folders.

While lombok.addLombokGeneratedAnnotation put in every generated code by Lombok annotation, another one named @lombok.Generated. This annotation informs Jacoco to not collect coverage from those codes.

Done, problem solved!

Finishing...

If you liked this post, please be sure to like and share 😄

If you want to know what I'm doing out there or ask any questions, feel free to look for me on social networks like @malaquiasdev.

To read more of my posts, go to MalaquiasDEV | Life, the code and everything else.

Discussion (0)