Use-Braces¶
Sourcery rule id: use-braces
¶
Description¶
Use block braces for ifs, whiles, etc.
Before¶
if (true)
do_something()
After¶
if (true) {
do_something()
}
Explanation¶
It is recommended to always use braces and create explicit statement blocks.
Using the allowed syntax to just write a single statement can lead to very confusing situations, especially where subsequently a developer might add another statement while forgetting to add the braces (meaning that this wouldn't be included in the condition).