Simon Josefsson wrote:
> what do you think about
> automating running 'indent' on gnulib source code?  Or clang-format,

It would be a bad idea.

There are different things that one can do to a source code:
  (a) Adding or removing spaces at the beginning of lines,
  (b) Reformatting: Changing the position of line breaks.
  (c) Reformatting and removing all comments.

All of these are bad ideas.

Why? Because the indentation levels, the position of line breaks, and
the comments all reflect the author's thoughts.

For this reason, I generally think and respect this rule:

  ** Only the author of some code is entitled to reformatting it. **

If someone reformats someone else's code (without understanding the
author's thoughts), it shows a lack of respect.

It's like going through a city and repainting every art work and
every sculpture in blue.

That's for manual reformatting.

Automated reformatting is even worse. I've seen tools reformatting

          tmp_length =
            (unsigned int) (sizeof (unsigned long int) * CHAR_BIT)
            + 1; /* turn floor into ceil */

to

          tmp_length =
            (unsigned int) (sizeof (unsigned long int) * CHAR_BIT) + 1; /* turn
                                                                           floor
                                                                           into
                                                                           ceil 
*/

and the corresponding developer then committed this change. I hope you will
acknowledge that this is 1. ugly, 2. does not reflect the author's thoughts.

> some projects have switched because it behaves better for them

That may be the case for projects with contributors who directly commit
code without following the agreed-upon coding style (in this case: GNU style).
But I find it better to tell contributors to change and format their
contribution according to our style, before we accept it, than to later
reformat their code without asking them for permission.

> at least we would then have a process for code indentation style
> conformance in gnulib.

What would it be good for?

If you find parts of gnulib source code hard to read, then please tell us
about it. In an honest, respectful face-to-face manner. But when someone
asks for process changes that disrespect the authors, and that without
mentioning a rationale or a benefit, guess how that feels?

Bruno




Reply via email to