Pattern: Nested solitary if
statement
Issue: -
Having an if
statement as the only statement inside another if
block without else
reduces readability. These conditions should be combined using logical operators.
Example of incorrect code:
if (foo) {
if (bar) {
}
}
if (foo) if (bar) baz();
Example of correct code:
if (foo && bar) {
}
if (foo && bar) baz();