Omitting Braces: Not Just A Matter Of Style
For example, when developers need to add to existing code and forget to add braces where the original statement only contained a single line of code, e.g.
The call to 'doSomethingElse()' is only meant to execute if 'condition' is true. However, omitting the braces in the If statement means doSomethingElse() will execute regardless of t he value of 'condition', hence the bug.
It may seem obvious but after that large lunch on a Friday.....who knows ;-)
From our individual metrics studies we found the Halstead Program Volume was the best individual metric for finding files that might contain bugs.
This means that, if you know nothing else about the file, a high Program Volume metric means the file is more likely to contain a bug. Our ongoing research indicates that a Program Volume value of 4000 reflects a 50% likelihood that a bug is present in the code. A Value of 5790 increases the likelihood to 90%.
For more details on this and other metrics that are indicators of possibly buggy code read our technical paper.