简体   繁体   English

SonarQube假阳性鱿鱼:S1450用于@Getter(lombok)注释字段

[英]SonarQube false positive squid:S1450 for @Getter (lombok) annotated fields

I think I have found a false positive while using the @Getter annotation from Project Lombok . 我想在使用Project Lombok@Getter注释时发现了误报。

In the following example class I got the warning "Private fields only used as local variables in methods should become local variables" ( squid:S1450 ). 在下面的示例类中,我收到警告“私有字段仅用作方法中的局部变量应该成为局部变量”squid:S1450 )。

public class Example {

    @Getter
    private String exampleField; // <-- squid:S1450

    public Example(final String value) {
        setExampleField(value);
    }

    private void setExampleField(final String exampleField) {
        this.exampleField = exampleField;
    }

}

Can someone confirm this? 有人能证实吗? Is it a bug in the SonarQube rule or is there something wrong with my class or with my understanding of this rule or the @Getter annotation? 它是SonarQube规则中的错误还是我的班级或我对此规则或@Getter注释的理解有问题?

Just for the sake of completeness: 只是为了完整起见:

  • Project lombok annotations or the generated methods are recognized correctly in other SonarQube rules. 项目lombok注释或生成的方法在其他SonarQube规则中被正确识别。 So I think my setup is fine. 所以我认为我的设置很好。
  • I have also tried to put the @Getter annotation on class level and I got the same warning. 我也尝试将@Getter注释放在类级别上,我也得到了同样的警告。
  • The warning is shown in SonarLint (in IntelliJ IDEA) and in the web interface of SonarQube. 警告显示在SonarLint(在IntelliJ IDEA中)和SonarQube的Web界面中。 So I think it's not an error while executing the analyzer. 所以我认为执行分析仪时并不是错误。
  • I have bound the SonarLint pluign in IntelliJ IDEA to our SonarQube Server and this remote connection works. 我已经将IntelliJ IDEA中的SonarLint插入到我们的SonarQube服务器中,并且此远程连接正常工作。

I have tested with the following versions: 我测试了以下版本:

  • SonarQube 6.0 SonarQube 6.0
  • SonarQube Java Plugin 4.2 SonarQube Java插件4.2
  • SonarLint (for IntelliJ IDEA) 2.3.2 SonarLint(适用于IntelliJ IDEA)2.3.2
  • IntelliJ IDEA 2016.2.5 IntelliJ IDEA 2016.2.5
  • Java 8 Java 8

You're right and I've created the following Jira ticket https://jira.sonarsource.com/browse/SONARJAVA-1924 . 你是对的,我已经创建了以下的Jira票证https://jira.sonarsource.com/browse/SONARJAVA-1924 Thanks for your feedback ! 感谢您的反馈意见 !

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM