Eclipse can do this in save actions. Perhaps we should enable project
specific save actions and have Eclipse fix this, run the formatter, organize
imports, etc... on save? This would ensure that an indent mistake like this
would not get checked in (the formatter would fix it) and ensure that
conditionals use blocks.

Brian

On Fri, Jul 18, 2008 at 1:40 PM, Tom Morris <[EMAIL PROTECTED]> wrote:

> I wasted a whole bunch of hours recently tracking down what turned out to
> be a bug in MDR that looked like this:
>
>                     if (item.endName.equals(assocStorable.getEnd2Name())) {
>                         assoc.refRemoveLink((RefObject) temp, thisObject);
>
>                     } else {
>                         assoc.refRemoveLink(thisObject, (RefObject) temp);
>                     if (item.isAggregate)
>                         ((RefObject) temp).refDelete();
>                     }
>
> where the visual appearance didn't match the actual logic.  Checkstyle
> probably would have flagged that the indentation didn't match the logic
> level, but to be extra safe I've made Checkstyle stricter and it will now
> require braces for all conditionals.  Please observe this requirement for
> new code and clean up any module that you are working on (no need to go back
> and rework things that aren't going to be touched for some other reason).
>
> I used to think single line if statements were ok without braces, but they
> just end up getting broken into two lines and indented and then someone adds
> an else arm and it's all just a slippery slope, so we're just going to
> require braces for everything.  I generally prefer vertically compact code,
> but, in this case, I think the extra white space is worth the additional
> safety.
>
> Tom
>

Reply via email to