简体   繁体   English

SonarLint - RedundantThrowsDeclarationCheck - 误报?

[英]SonarLint - RedundantThrowsDeclarationCheck - false positive?

In the following code I get a warning from the squid:RedundantThrowsDeclarationCheck rule on the Foo1Exception (behind the throws keyword): Remove the redundant '!unknownSymbol!' thrown exception declaration(s). 在下面的代码中,我从squid:RedundantThrowsDeclarationCheck收到一个警告squid:RedundantThrowsDeclarationCheck关于Foo1Exception squid:RedundantThrowsDeclarationCheck规则(在throws关键字后面): Remove the redundant '!unknownSymbol!' thrown exception declaration(s). Remove the redundant '!unknownSymbol!' thrown exception declaration(s).

Foo.java: Foo.java:

public class Foo {

    public static boolean bar(final String test) throws Foo1Exception, Foo2Exception {

        if (test.startsWith("a"))  {
            throw new Foo1Exception();
        } else if (test.startsWith("b")) {
            throw new Foo2Exception();
        } else if (test.startsWith("c")) {
            return true;
        }

        return false;
    }

}

Both exceptions are decrlared in seperate files: 这两个例外都在单独的文件中声明:

Foo1Exception.java: Foo1Exception.java:

class Foo1Exception extends Exception {}

Foo2Exception.java: Foo2Exception.java:

class Foo2Exception extends Exception {}

I think this is a false positive, isn't it? 我认为这是假阳性,不是吗? Also interesting: I don't get this message directly in SonarQube (web interface) only in the SonarLint plugin in IntelliJ IDEA. 同样有趣的是:我没有直接在SonarQube(Web界面)中直接在IntelliJ IDEA的SonarLint插件中获得此消息。 Any Ideas? 有任何想法吗?

I'm using: IntelliJ IDEA 2016.2.2; 我正在使用:IntelliJ IDEA 2016.2.2; SonarLint 2.3 (with working server binding); SonarLint 2.3(带工作服务器绑定); SonarQube 5.6; SonarQube 5.6; SonarQube Java Plugin 4.0; SonarQube Java插件4.0; Java 8 Java 8

这似乎是在SonarLint 2.3.1修复的

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

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