I agree with you that braces should always be used. Personally, I do have one exception though, and that is if the statement following it is on the same line. That way, it is one line, instead of 3 lines, which makes it more readable. If the 'if' statement spans multiple lines, I always include braces, even if there is only one single statement involved. But that is just me...

I think the rule is already active in Checkstyle. I think I just chose to ignore it here.

In general (not just this Checkstyle rule), is it allowed to ignore checkstyle errors, if one believes that the code would be better if the rule is ignored for a specific instance; that is, in case of false positives?

Dennis


Luc Maisonobe wrote:
Hi all,

The provided patch for MATH-599 includes a number of no-brace if statements like the following ones:

+                if (method == Method.ILLINOIS) f0 *= 0.5;
+                if (method == Method.PEGASUS) f0 *= f1 / (f1 + fx);

I'm not sure if we have an unwritten rule for this, but personally I dislike this style a lot. Checkstyle provides a NeedBraces rule to avoid this.

What about activating this rule ?

Luc

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to