org.sonar.l10n.java.rules.squid.RedundantThrowsDeclarationCheck.html Maven / Gradle / Ivy
The newest version!
An exception in a throws
declaration in Java is redundant if:
- It is listed multiple times
- It is a subclass of another listed exception
- It is a
RuntimeException
, or one of its descendants
The following code:
void foo() throws MyException, MyException {} // Non-Compliant - should be listed once
void bar() throws Throwable, Exception {} // Non-Compliant - Exception is a subclass of Throwable
void baz() throws RuntimeException {} // Non-Compliant - RuntimeException can always be thrown
should be refactored into:
void foo() throws MyException {} // Compliant
void bar() throws Throwable {} // Compliant
void baz() {} // Compliant
© 2015 - 2025 Weber Informatics LLC | Privacy Policy