What language is this for: Java
Which rule: java:S2583: Conditionally executed code should be reachable
Are you using: Sonarqube Enterprise Edition - Version 9.9.4 (build 87374)
This rule seems to fail when there is an assignment in a typed catch block, when the exception is not checked.
Here is an example:
public class MyTransactionInterceptor extends TransactionInterceptor {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
RuntimeException ex = null;
Object res = null;
try {
res = super.invoke(invocation);
} catch (RuntimeException e) {
ex = e;
}
if (ex != null) {
throw ex;
}
return res;
}
}
In the code, the line if (ex != null)
is marked because Sonarqube thinks that ex is always null.