I run popular Java Code Quality tool SonarQube and was observing its suggestions. I see that it reported below issue with 'Major' severity,
You could see compliant and non-compliant piece of code for that rule as below,
if(something) {
executeTask();
} else if (somethingElse) { // **Compliant**
doSomethingElse();
}
else { // **Noncompliant**
generateError();
}
I feel that, it is developer's discretion and at least that issue should not be reported with 'Major' severity. ('Minor' or 'Info' severity could be fine with proper justification.)
Do you have any justification about why such recommendation?
Secondly, the question to the audience who are dealing with code quality tools for some considerable time, overall how serious I need to be with code quality tool?
(I found some articles, here and here, that actually endorses the 'Non Compliant' way of writing if-else or try-catch-finally.)
It's not surprising that your code is treated as non-compliant - it violates Java Code Conventions. It's up to you to follow code conventions or not, but consider the fact that code written in common style is much more easier to understand.
According to the Java Code Conventions if-else statements should have the following form:
And try-catch statements should have the following format: