Search code examples
javaintellij-ideasonarqubesonarlint

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).

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:

class Foo1Exception extends Exception {}

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. Any Ideas?

I'm using: IntelliJ IDEA 2016.2.2; SonarLint 2.3 (with working server binding); SonarQube 5.6; SonarQube Java Plugin 4.0; Java 8


Solution

  • This seems to be fixed in SonarLint 2.3.1.