Is there a way to enforce curly braces for if stat...
# announcements
j
Is there a way to enforce curly braces for if statements and loops in Kotlin, or even better, automatically add it (like the code formatter in Ktlint does)? I noticed there are options in
.editorconfig
but it doesn't seem to do anything
Copy code
ij_any_if_brace_force = always
ij_any_for_brace_force = always
Ktlint seems to have such options, but it's marked as experimental and it will only show warnings What are other teams using for automated code formatting in Kotlin?
👍 1
s
We only rely on IDEA doing it on the go since we only want to auto format on changed lines in a commit. Have not looked much around if that is possible with tools like Ktlint but I assume not.
j
how does one setup IDEA to do it, is this via .editorconfig or is there another place where you can set it up?
s
Code -> Reformat File -> Only VCS changed text
We manually get people to set this setting
I think this is the behavior with Reformat code in the commit dialog
j
ah, under Version control, there are Before Commit options, i guess this is a good start Thanks for the input!