sonarqube + lombok = false positives

后端 未结 2 422
半阙折子戏
半阙折子戏 2020-11-29 08:09
import lombok.Data;

@Data
public class Filter {
    private Operator operator;
    private Object value;
    private String property;
    private PropertyType prope         


        
相关标签:
2条回答
  • 2020-11-29 08:38

    This case should be perfectly handled by SonarJava. Lombok annotations are taken into account at least since version 3.14 (SONARJAVA-1642). The issues you are getting are resulting from a misconfiguration of your Java project. No need to write any custom rules to handle this, this is natively supported by the analyzer.

    SonarJava reads bytecode to know which annotation are used. Consequently, if you are not providing bytecode from your dependencies, on top of bytecode from your own code, the analyzer will behave erratically.

    In particular, setting property sonar.java.libraries should solve your issue. Note that this property is normally automatically set when using SonarQube maven or gradle scanners.

    Please have a look at documentation in order to correctly configure your project: https://docs.sonarqube.org/display/PLUG/Java+Plugin+and+Bytecode

    0 讨论(0)
  • 2020-11-29 08:45

    I added following property to jenkins Sonar analysis properties. And work for me.

    sonar.java.libraries=/jenkins/jenkins-user-home/.m2/repository/org/projectlombok/lombok/1.16.20/lombok-1.16.20.jar
    

    lombok v1.16.20 is lombok version on my project.

    0 讨论(0)
提交回复
热议问题