Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sonar + Lombok false positives on @Data annotation

I am getting a lot code smells from lombok generated code in Sonar. F.E.:

Method Dto.hashCode() stores return result in local before immediately returning it


Dto.equals(Object) is excessively complex, with a cyclomatic complexity of 58

How can I point out sonar that this should be skipped from analyze?

UPDATE

I've tried it already. My lombok.config file in root directory is:

config.stopBubbling = true
lombok.addLombokGeneratedAnnotation = true
lombok.equalsAndHashCode.callSuper = call

It doesn't helps

I've tried it already: sonarqube + lombok = false positives I've updated: sonar-project.properties in root directory to:

sonar.sources=src/main
sonar.tests=src/test
sonar.language=java
sonar.java.binaries=build/classes
sonar.junit.reportPaths=build/test-results/test/
sonar.jacoco.reportPaths=build/jacoco/jacocoTest.exec
sonar.java.libraries=.gradle/caches/**/lombok-*.jar

It doesn't work either.


Please don't close it. It is not duplication.

like image 702
masterdany88 Avatar asked Oct 07 '19 10:10

masterdany88


1 Answers

Methods generated by lombok need to be annotated with @Generated. Sonarqube will then ignore them.

Just add a file lombok.config in the project root directory, with the following content:

lombok.addLombokGeneratedAnnotation=true
like image 68
Benoit Avatar answered Sep 28 '22 16:09

Benoit