Community
Participate
Working Groups
In Window→Preferences→Java→Editor→Save Actions→Configure→Code Style→Control Statements→Use blocks in if/while/for/do statements Actual behavior (for each of the three settings): * "Always": for (int i = 0; i < 10; i++) { if (i < 5) { System.out.println(i); } else { System.out.println(i / 2); } } for (int i = 0; i < 10; i++) { if (i < 5) { System.out.println(i); } } for (int i = 0; i < 10; i++) { System.out.println(i); } for (int i = 0; i < 10; i++) { throw new RuntimeException(); } * "Always except on single 'return' or 'throws' statements": for (int i = 0; i < 10; i++) { if (i < 5) { System.out.println(i); } else { System.out.println(i / 2); } } for (int i = 0; i < 10; i++) { if (i < 5) { System.out.println(i); } } for (int i = 0; i < 10; i++) { System.out.println(i); } for (int i = 0; i < 10; i++) throw new RuntimeException(); * "Never": for (int i = 0; i < 10; i++) if (i < 5) System.out.println(i); else System.out.println(i / 2); for (int i = 0; i < 10; i++) if (i < 5) System.out.println(i); for (int i = 0; i < 10; i++) System.out.println(i); for (int i = 0; i < 10; i++) throw new RuntimeException(); Expected (missing) behavior: * "Except on 'simple' statements": for (int i = 0; i < 10; i++) { if (i < 5) { System.out.println(i); } else { System.out.println(i / 2); } } for (int i = 0; i < 10; i++) if (i < 5) System.out.println(i); for (int i = 0; i < 10; i++) System.out.println(i); for (int i = 0; i < 10; i++) throw new RuntimeException(); I would either like this behavior as a fourth option or in stead of the middle option. For lack of a better word, I call every single-line statements and statement that had it's braces removed because of this rule, a 'simple statement'. A better, but less user-friendly, term would be 'statement tree without any splits'.