When reviewing code, I prefer to read if
statements that explicitly demonstrate that a fork in code execution may occur:
if ( isFoo(baz) ) {
runBar();
}
When scanning hundreds of lines of the nonindented version, it is not obvious that a conditional may or may not occur:
boom += 1;
baz = getBaz(boom);
if (isFoo(baz)) runBar();
boing = boom + baz;
So when is it considered all right to single-line if statements? I'm willing to put up with it if the conditional is on a die(), return, or exception, because in those cases at least the current method ends.
if (isFoo(baz)) die("No more foo!");
Are there any other "good" uses for single-line if statements? How strictly should the practice be avoided? Note that I am explicitly asking about the lack of an indented line to indicate that a condition may or may not occur, I am not asking about the use of braces. Although I would appreciate all opinions in the comments, answers should address objective reasoning, such as maintainability or extensibility of code.
This is not a dupe of Single statement if block - braces or no because this question does not ask about braces. This is not a dupe of Single Line Statements & Good Practices because that question does not address the crux of this question: the ability to determine that some lines of code may or may not be run, thus leading to divergent code paths.