[Ns-developers] script for coding style

Mathieu Lacage mathieu.lacage at sophia.inria.fr
Mon Jan 11 00:38:08 PST 2010


On Sun, 2010-01-10 at 21:48 -0800, Tom Henderson wrote:

> > --level=1: checks for missing spaces
> 
> This works pretty well, AFAICS.  I found that it missed only this one:
> 
>    Ptr<ChordVNode> virtualNode = DynamicCast<ChordVNode>(chordNode);

I fixed that one in my http://code.nsnam.org/mathieu/indent

> > --level=2: checks for missing newlines and braces around single-line
> statements
> 
> the program makes this error:
> 74c75,76
> < class ChordIpv4 : public Application
> ---
> > class ChordIpv4
> >   : public Application

Yes. Unfortunately, I see no way to handle this case nicely with the
current uncrustify. This newline insertion is controlled by the same
parameter that controls the insertion of a newline before the colon in:

Foo::Foo ()
  : ...
{
}

So, if we disable the newline between class and ':', we also disable the
newline between Foo () and ':'.

Since this is not doing what we want, we can set this parameter to
'ignore' to make uncrustify not change the existing code in this case. I
have just done that.

>Maybe what would be better to do in this case, if line splitting is
not 
> robust, is print out a warning message at all levels such as:
> "Warning:  line NNN is greater than 128 columns long"
> and let the user fix.

Maybe we can simply disable line splitting. I have just done that in the script.

> and Andrey also pointed out the namespace ns3 \n newline that occurs.

That one, I am a bit torn about: I just made the script do what andrey
and yourself suggested since this is what the current coding style
suggests, that is: 'namespace ns3 {'

However, I would argue for changing the coding style in this regard
because, from a consistency perspective, it currently recommends that we
always insert a newline between a statement and an open brace so, I
would tend to suggest that we do 'namespace ns3\n{' instead.

> this level also removes some trailing whitespace even on lines where 
> there are otherwise no changes, e.g.:
> 301c304
> < void
> ---
> > void

How can I reproduce ?

Mathieu



More information about the Ns-developers mailing list