[webkit-dev] unwritten rules of webkit style

TAMURA, Kent tkent at chromium.org
Wed Sep 2 20:15:25 PDT 2009



> {} should be added in this case:


>> if (condition1         && condition2)
>>      statement;


> Not according to current WebKit style because it is a single line
> statement.


I don't like this rule. We need to be careful to add/remove a sentence in an
existing block, need to guess how many sentences to be added when we add
"if".

A few days ago, this rule brought a real bug to me.

Existing code:
   if (attr->name() == fooAttr)
       doSometing();
   else if (attr->name() == barAttr) ...

I added "if" like:

   if (attr->name() == fooAttr)
       if (isBaz())
           doSometing();
   else if (attr->name() == barAttr) ...

The "else" clause unexpectedly attached to "if (isBaz())"
I wasted about an hour to found this bug.

-- 
TAMURA Kent
Software Engineer, Google



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20090903/76db4566/attachment.html>


More information about the webkit-dev mailing list