Reputation: 319
SonarQube supports partially Lombok annotations (getters - setters etc). However, it does not still support @EqualsAndHashCode
and @ToString
methods.
I have tried all answers on StackOverflow and others sites. However, it does not work in my case.
Is there any way to say SonarQube or Jacoco, that do not analyze this annotation(s) or do not include them in test coverage results or what would be your solution to this problem?
Upvotes: 2
Views: 9525
Reputation: 1136
Starting with Jacoco 0.7.10, it is now possible that Lombok-generated code gets excluded by setting the flag lombok.addLombokGeneratedAnnotation
to true
in lombok.config.
More on http://www.rainerhahnekamp.com/ignoring-lombok-code-in-jacoco
Upvotes: 8
Reputation: 34472
You can configure Lombok to generate @SuppressFBWarnings
on generated code. Possible, you can configure JaCoCo to listen to that annotation. Unfortunately, @javax.annotation.Generated
has retention source, so that's no use for you.
Disclosure: I am a Lombok developer
Upvotes: 3
Reputation: 10833
Let's put SonarQube out of the equation as it is just the tool revealing the issue.
JaCoCo works by instrumenting bytecode: This means that it adds some instructions (probes) at particular places in bytecode and see which probes are hit during test runs or not.
On its side Lombok generates methods at bytecode level. Those generated method are then instrumented by JaCoCo and not covered by your tests.
So you would have to configure JaCoCo to ignore those methods, or to instrument classes before lombok does its magic, or write tests for those generated methods.
Upvotes: 4