4.1.1 Braces are used where optional Braces are used with if, else, for, do and while statements, even when the body is empty or contains only a single statement.
I hate when people omit curly braces for some insane reason. At least Google has my back.
You wouldn't need to protect them from messy/obscure/unnatural/asymmetrical/old brace placement initially instated due to monitor constraints in the stone age if you place them where it makes most sense Now that we can afford it thanks to the luxuries introduced a decade ago.
Consider when the return is on the next line (more common imo). If you insert a line before the return (perhaps a print) then the entire if statement logic is no longer what you intended. Not explicitly stating the block boundaries makes it easier to introduce bugs.
You have to consider refactors performed by tools like Eclipse, and the diffs those generate as well as the stupid bugs reason.
If you have a huge codebase (like Google), it becomes occasionally necessary to run a refactor that touches thousands of files, and if you don't make formatting very consistent it takes code reviewers a lot less mental effort to review dozens or hundreds of files that got touched.
Ideally, you want to make it absolutely formulaic. If you can do that, then you don't even need human reviewers to look at it because you can guarantee the safety of the change.
36
u/[deleted] Jan 29 '14
I hate when people omit curly braces for some insane reason. At least Google has my back.