[PATCH] Add utility to check for indentation in files or patches
Simo
simo at samba.org
Mon Apr 9 22:18:11 UTC 2018
Attached find a new version that deals with python3 properly and
also has better handling of indent, by spitting only a diff file with
the propsed diff you should apply to pass it's rules.
Previously the code was trying to line match and give a generic error
with the line number but that doesn't work because indent can change
lines by wrapping or unwrapping so the line numbers would make no sense
on longer files.
I have no yet addressed the space and parenthesized issues in this
specific email simply because I ran out of time and I am not sure we
actually do not want them.
I am open to changing these though if more people agree on the need for
changing them.
Simo.
On Mon, 2018-04-09 at 15:35 -0400, Simo via samba-technical wrote:
> On Mon, 2018-04-09 at 22:17 +1000, Martin Schwenke wrote:
> > On Mon, 09 Apr 2018 07:51:56 -0400, Simo <simo at samba.org> wrote:
> >
> > > On Mon, 2018-04-09 at 20:48 +1000, Martin Schwenke wrote:
> > > > It just seems to blow up on some commits with a traceback. Can someone
> > > > please explain what I'm doing wrong?
> > >
> > > Do you have 'indent' installed ?
> > > I probably need to catch the exception better, I changed this part from
> > > the original stuff, as it was using emacs ...
> >
> > I didn't but I do now. Much better! Thanks! :-)
> >
> > A couple of things that we might not want:
> >
> > * No space before or after binary operator
> >
> > We have "good" examples in README.Coding without spaces around binary
> > operators. For example, in a for-loop and in a calculation involving
> > sizeof().
> >
> > * Parenthesized return expression
> >
> > We don't have a rule against this.
> >
> > In all the simple cases, doing this is bad style. However, for a
> > complex expression it might provide clarity.
> >
> > For example, in the same way that:
> >
> > x = (y.foo == z.bar);
> >
> > gains clarity from the parentheses, I think the following does too:
> >
> > return (y.foo == z.bar);
> >
> > Or, perhaps, the latter is against the guidelines because we should
> > be doing:
> >
> > ok = (y.foo == z.bar);
> > return ok;
> >
> > However, since we have access to y.foo and z.bar in a debugger, we
> > can easily check what the return value will be, so I think the
> > original is OK.
> >
> > Not sure... :-)
>
>
> Thanks,
> I am updating the code to work with python3 (the original catered for
> python 2.6 ...) and I will add measures to deal with your feedback too,
> although I have to say I think I may prefer to keep both rules above as
> that's what indent also does ?
> Otherwise I need to check how to suppress that in indent I guess.
>
> But I'll look into it.
>
> Simo.
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-utilities-to-check-style.patch
Type: text/x-patch
Size: 20896 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20180409/ec307658/0001-Add-utilities-to-check-style.bin>
More information about the samba-technical
mailing list