I have gradle(6.9) springboot(2.7.0) project with following dependecy
compileOnly 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
testCompileOnly 'org.projectlombok:lombok:1.18.22'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
while analysis with sonar (version is 8.9) it shows Missing Ctor rule even if i had used @NoArgsConstructor it shows Class should define a constructor.The same error shows for entity class annotated with @Entity
I have tried to add the following in sonar-project.properties
sonar.java.libraries=build/resources/main/META-INF/resources/lombok.jar
and the following in build.gradle
property "sonar.java.libraries","build/resources/main/META-INF/resources/lombok-1.18.22.jar"
but not working.
given the following in the lombok.config
lombok.addLombokGeneratedAnnotation = true
it will helps only to improve the coverage of @NoArgsConstructor,@Getter etc
I found that .class file having the generated constructor but sonar is not analysing this properly.That sonar rule is from checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.MissingCtorCheck
I can't suppress this rule.expecting other solutions for this
After so many days of effort, I got the solution.
Usage of lombok is stepping on checkstyle limitation https://checkstyle.org/writingchecks.html#Limitations read single file as text, checkstyle is not type-aware tool.That's why the binaries,classpath dependencies were not taken on that version.I found that this rule is generated by sonar checkstyle by analyzing the checkstyle-result.xml in the build folder.This will resolved in latest version. I have upgraded the sonar to 10.1 version and checkstyle 10.12.1.Now the issue resolved