Closed klues closed 5 years ago
change in the formatter file which has this effect: (1) before:
if (object == null) return;
(2) afterwards:
if (object == null) return;
I like style (2) much more. To my mind every if clause that has more than 1 line should have curly brackets, see e.g. https://www.imperialviolet.org/2014/02/22/applebug.html
I think an if-statement without brackets is bad code and very likely to cause unintended program flow if somebody adds a statement to the if-body. So, I think we should always format with braces, e.g.:
if(object==null) { return; }
always braces-format would be ok for me, however the formatter then will format like this:
if (!propEnabled) {
return;
}
which is very space consuming. I don't know if it's possible to tell the formatter to format this in one line. To my mind statements like if (!propEnabled) return;
without braces are not really bad code because (at least for me) it's obvious that I have to add braces if I want to add a statement.
I think this should be merged regardless of any agreement to only do if-statements with curly braces in the future. As long as there are if-statements without braces in the code base it is always better to format them in one line than in two lines (in my opinion).
can we merge this?
change in the formatter file which has this effect: (1) before:
(2) afterwards:
if (object == null) return;
I like style (2) much more. To my mind every if clause that has more than 1 line should have curly brackets, see e.g. https://www.imperialviolet.org/2014/02/22/applebug.html