[Development] Resolving coding style contentions
Matthew Woehlke
mwoehlke.floss at gmail.com
Wed Nov 21 20:57:30 CET 2018
On 21/11/2018 14.35, Elvis Stansvik wrote:
> Den ons 21 nov. 2018 kl 20:28 skrev Matthew Woehlke:
> We use the following .clang-format at work:
> [snip]
>
> I'd say it's Qt/KDE-ish. Certainly not perfect by any means, and yea
> clang-format can do some quite annoying stuff (the re-flowing you
> mention).
>
> But for the most part, we just get on with it and live with some less
> then perfect formatting for some things. All in all it's been a real
> relief for all involved since we started mandating all code to be
> auto-formatted, and saves a lot of time at review.
Sure. I'm not against automatic styling tools, by any means! I just
wanted to point out that a) clang-format isn't the only plausible
option, and b) clang-format has shortcomings, especially if the style
you want isn't quite the style *it* wants.
For a large project, especially one with a large group of contributors,
forcibly changing the existing code style can be... problematic.
> I'll definitely look at uncrustify though, thanks for the tip (and for
> building it!).
I'm not the author; just one of the current active contributors.
However, I do recommend it. It has some faults (but it's also under
active development and patches are encouraged), however I think it is a
better tool than clang-format in some ways.
Clang-format is a tool for dictating *to* you how to format your code.
If you disagree with it, you are wrong, because clang-format is always
right.
Uncrustify is a tool for helping to enforce a style that *you* choose.
It will enforce as much or as little as you like with whatever
subtleties you want.
(Uncrustify is also stupidly easy and quick to build compared to clang,
which is something to keep in mind if you're expecting developers to run
it locally.)
--
Matthew
More information about the Development
mailing list