[Gluster-devel] if/else coding style :-)

Anand Avati avati at gluster.org
Mon Oct 13 21:40:03 UTC 2014


On Mon, Oct 13, 2014 at 2:00 PM, Shyam <srangana at redhat.com> wrote:

> (apologies, last one on the metrics from me :), as I believe it is more
> about style than actual numbers at a point)
>
> _maybe_ this is better, and it is pretty close to call now ;)
>
> find -name '*.c' | xargs grep else | wc -l
> 3719
> find -name '*.c' | xargs grep else | grep '}' | wc -l
> 1986
> find -name '*.c' | xargs grep else | grep -v '}' | wc -l
> 1733


Without taking sides: the last grep is including else without either { or }.

[~/work/glusterfs]
sh$ git grep '} else {' | wc -l
    1331
[~/work/glusterfs]
sh$ git grep 'else {' | grep -v '}' | wc -l
     142

So going by just numbers, "} else {" is 10x more common than "}\n else {".
I also find that believable based on familiarity of seeing this pattern in
the code. Either way, good idea to stick to one and not allow both in
future code.

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://supercolony.gluster.org/pipermail/gluster-devel/attachments/20141013/76b8eceb/attachment-0001.html>


More information about the Gluster-devel mailing list