-
Notifications
You must be signed in to change notification settings - Fork 284
Description
I suggest to have an option, to rewrite multiline if-statements to always use curly braces.
Single line should be left untouched in general or optionally formatted.
I used that style before, as it is supported by IntelliJ and I am missing this in scalafmt.
A good discussion, if anybody really needs to get convinced, can be found on stackoverflow.
There is even a real world example of an apple bug from 2014.
And scalastyle supports this too.
They gave the option to make an exception for double lines.
I think this is already to dangerous and should force braces too.
I think, if you turn this option on in IntelliJ, the editor automatically inserts braces if you enter a newline after the if conditions parentheses are closed.
Is it possible to do the same if the scalafmt formatter is selected in IntelliJ?
Example
So this code
if(shouldDoThis)
doThis()
else
doThat()
becomes
if(shouldDoThis){
doThis()
} else {
doThat()
}