Sonar-scanner + Lombok + Gradle = False-Positives codesmells


We are using:

  • Sonar-scanner-cli v.

We use Gradle to build our Java code and sonar-scanner to analyse it, but sonar-scanner generates false-positive codesmells regarding Lombok library, for example: “Remove this unused “fname” private field” or “Add a private constructor to hide the implicit public one”.

We have faced similar issues with sonar-scanner and Maven projects as well, and we used the following plugin: in order to generate lombok .jar files. Then we set property accordingly to point to the location of these .jars, in our file and the problem was solved.

However, we cannot find anything similar in order to generate lombok .jar files for Gradle projects. Do you know if there is such a setting or maybe another way to resolve this issue in Gradle? Please note that we need to avoid creating custom rules.

Thank you


Unfortunately, without the binaries, the java analyzer is not going to be able to understand the code generated by lombok annotations. The java analyzer is only supporting lombok at best. We try to kill the noise, but ultimately, we need the jars to be able to operate without too many FPs.

Currently, there are also no particular settings in our analyzers to be set to handle lombok better.

However, if the lombok plugin for gradle is systematically placing generated bytecode in the same folder, we could try to check for that folder before starting the analysis. However, in order to do so, we would need more information about how lombok is working with gradle, and this is out of our scope at the moment.