Re: [PATCH 00/13] nvdimm: Use more common kernel coding style
From: Nick Desaulniers
Date: Thu Sep 12 2019 - 18:58:31 EST
On Thu, Sep 12, 2019 at 2:58 PM Miguel Ojeda
<miguel.ojeda.sandonis@xxxxxxxxx> wrote:
>
> On Thu, Sep 12, 2019 at 11:08 PM Joe Perches <joe@xxxxxxxxxxx> wrote:
> >
> > Please name the major projects and then point to their
> > .clang-format equivalents.
> >
> > Also note the size/scope/complexity of the major projects.
>
> Mozilla, WebKit, LLVM and Microsoft. They have their style distributed
> with the official clang-format, not sure if they enforce it.
>
> Same for Chromium/Chrome, but it looks like they indeed enforce it:
>
> "A checkout should give you clang-format to automatically format C++
> code. By policy, Clang's formatting of code should always be accepted
> in code reviews."
>
> I would bet other Google projects do so as well (since Chandler
> Carruth has been giving talks about clang-format for 7+ years). Nick?
So Google3 (the internal monorepo that Android, Chromium, ChromiumOS,
Fuchsia are not a part of) is pretty sweet. You cannot even post code
unless the linter has been run on it (presubmit hook), which for our
~350 millions LoC of C++ is clang-format. If you bypass local
presubmit hooks, our code review tool ("critique") won't let you
submit code that fails lint presubmit checks. I suspect the initial
conversion was probably committed by bots.
>
> I hope those are major enough. There is also precedent in other
> languages (e.g. Java, C#, Rust).
Yep! Other people coming to C/C++ from these languages find the
discussion about tabs vs spaces to be highly entertaining! When you
have an automated code formatter and an agreed upon coding style (and
hopefully enforcement), you save so much time from avoided bikesheds!
Don't like the codebase's coding style? Then write the code how you
like and just run the formatter when you're done (might not help with
conventions though, maybe that's where checkpatch.pl can shine).
Done! No more wasted time on what color to paint the bikeshed!
--
Thanks,
~Nick Desaulniers