When an if is placed on the same line as the closing } from a preceding if, else or else
if part, it is either an error - else is missing - or the invitation to a future error as maintainers fail to understand that the
two statements are unconnected.
This code is confusing
if (condition1) {
// ...
} if (condition2) { // Noncompliant
//...
}
Either the two conditions are unrelated and they should be visually separated
if (condition1) {
// ...
}
if (condition2) {
//...
}
Or they were supposed to be exclusive and you should use else if instead
if (condition1) {
// ...
} else if (condition2) {
//...
}