asterics / AsTeRICS

The Assistive Technology Rapid Integration & Construction Set
http://www.asterics.eu
Other
55 stars 27 forks source link

keep simple if on one line -> true #284

Closed klues closed 5 years ago

klues commented 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

deinhofer commented 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; }

klues commented 5 years ago

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.

klues commented 5 years ago

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).

klues commented 5 years ago

can we merge this?