Community
Participate
Working Groups
Build ID: I20070809-1105 Steps To Reproduce: 1. Paste the code "Before" in a java file 2. Choose Source -> Clean up... 3. Create/Use a profile which only have: * Remove unnecessary blocks 4. Apply, you should get the code "After" More information: The clean up remove the else block but leave the if block. It make sense from an AST point of view, but not from a programmer-trying-to-have-clear-code point of view. Before ==================================== public class ElseBlock { public int foo(boolean b1, boolean b2) { if (b1) { if (b2) return 0; else return 1; } else { if (b2) return -1; else return -2; } } } After ==================================== public class ElseBlock { public int foo(boolean b1, boolean b2) { if (b1) { if (b2) return 0; else return 1; } else if (b2) return -1; else return -2; } } I think the clean up is too aggressive. A difference should be made between "simple single statement" and "complex single statement". Simple statement would be function call, assignement, etc. Complex statement would be loops, if, switch... It could be an option in the clean up dialog: Use blocks in if/while/for/do statements * Always * No block for single 'return' or 'throw' statments (spell error ?) * No block for single simple statements (Added) * No block for single statments (spell error?) I hope you like the idea.
*** This bug has been marked as a duplicate of bug 185669 ***