> On Feb 24, 2015, at 2:59 PM, Leif Hedstrom <zw...@apache.org> wrote:
> 
> Hi,
> 
> clang-format has finally gotten to the point where we can get it to format 
> our code similar, but not quite identical, to what we have today. Doing all 
> formatting programmatically has several benefits:
> 
> It’s no longer up to subjective or personal preferences, we’ll learn to live 
> and love the clang-format coding style.
> It can be automated.
> It can also be used as a tool for people who want to work / see code in a 
> different style, but commit in our standard style.


There doesn’t seem to be any major concerns or obstacles for doing this, so I 
think we should. After discussing with various people (thanks everyone for the 
input and help!), we have made a few changes to the initial clang-format config 
(all of which are in our git repo):

1) Increased line length to 132 characters (from 120). This will fit nicely for 
printing in landscape mode on all our 80-column matrix printers. ( :-) if that 
wasn’t obvious).

2) Fixed a couple of outright wrong configs, e.g. on breaking for ternary 
operators.

3) Indent at the opening of name spaces.



Now, there will be code that does not format nicely, due to how our code is 
currently laid out. One such example was a case where we (presumably) 
deliberately broke a string up into several parts, for no apparent reason. 
Combining this string into a string that is still < 132 characters fixed that 
problem.

But this means that when you fix such odd formatting, it’s important that you 
don’t just restore the old format! You must fix the underlying cause for why 
clang-format “messed up”, make those changes, and then format the code 
according to our specs (or run clang-format on it, e.g. using the clang-format 
Emacs mode).

I will update the Wiki coding standard with the changes above, and details on 
clang-format as soon as we’ve made the initial clang-format run. The 
expectation is also that we should be able to run clang-format on the code in 
master at any given time, and there should be no changes :-). Of course, over 
time clang-format might fix bugs etc. that could fix broken indentations, but 
we’ll deal with that if/when it happens. I will however fix any broken 
indentation as it happens.

Last chance to object to this, or it will happen Real Soon! :-)

Cheers,

— Leif

Reply via email to