If any part of if else statement requires braces add the to all
Currently "Enforce if body is multi-line" formats following like this
Multiple line it's this
if (variable1)
{
func1();
func2();
}
else if (variable2)
func1();
else
func1();
Single line statements it's like this
if (variable1)
func3();
else if (variable2)
func1();
else
func1();
Add option to add braces to all blocks in if else statement if one needs it so it would be make it like this
Multiple line it's this
if (variable1)
{
func1();
func2();
}
else if (variable2)
{
func1();
}
else
{
func1();
}
Single line statements it's like this
if (variable1)
func3();
else if (variable2)
func1();
else
func1();
Please sign in to leave a comment.
Hi guys,
I like to up this post cause in "Rider for Unreal Engine" in c++ code style there is no option to force the braces for single statement.
Or maybe i miss something but in "c# code style" the configuration is pretty clear in the "Syntax Style" panel, which is missing in c++:
Thanks!
Hello,
I suggest trying the latest version of Rider.
The below set of settings will let you format the code as you described ( Code | Reformat and Cleanup" action):
Settings | Editor | Code Style | C++
Syntax Style
Braces | Remove redunant = Yes
Braces | In "if" statement = "Enforce if any part requires braces."
Line Breaks and Wrapping
Break line in a single embedded statement = "Force line breaks."
Let me know if you have any questions.