[cmake-developers] Code style auto-formatting

Stuermer, Michael SP/HZA-ZSEP michael.stuermer at schaeffler.com
Tue Nov 17 05:38:39 EST 2015



> -----Original Message-----
> From: Kislinskiy, Stefan [mailto:s.kislinskiy at Dkfz-Heidelberg.de]
> Sent: Tuesday, November 17, 2015 10:11 AM
> To: Stuermer, Michael SP/HZA-ZSEP; CMake Developers
> Subject: AW: [cmake-developers] Code style auto-formatting
> 
> Do you know ClangFormat[1]? Pretty popular choice these days. You just put
> a format description file into your repository (which can be based on popular
> styles + your exceptions to keep the file rather small). It can be integrated
> into many editors including the Visual Studio IDE. 
 
Sounds promising. For CMake a configuration file would be needed which changes the existing code as less as possible. If something like that exists and it is easy to handle I believe some developers might use it. Still someone would have to do the work of setting up/configuring everything :-) .

> You probably want to add a
> hook to your git repository to automatically format your code when
> committing. See the link for details.

Ok, this is only my opinion, but changing the actual  changeset automatically within a commit hook is one oft he worst things you can do with hook scripting. Style checking or refusal of badly styled code is ok.

> 
> Best regards,
> Stefan
> 
> [1] http://clang.llvm.org/docs/ClangFormat.html
> 
> ________________________________________
> Von: cmake-developers [cmake-developers-bounces at cmake.org] im
> Auftrag von Stuermer, Michael  SP/HZA-ZSEP
> [michael.stuermer at schaeffler.com]
> Gesendet: Dienstag, 17. November 2015 09:14
> An: CMake Developers
> Betreff: Re: [cmake-developers] Code style auto-formatting
> 
> I asked something similar half a year ago:
> 
> https://cmake.org/pipermail/cmake-developers/2015-June/025498.html
> 
> In short, there is no fully automated style checking. If someone would come
> up with a tool & configuration I would love to use this. So far I tested astyle
> and the C++ edition of ReSharper (unfortunately quite expensive).
> 
> The more complicated thing would be, that you have to run the formatter
> over all existing code and thus you would introduce a huge amount of
> meaningless changes. I believe (and partially understand) many developers
> here on the list wouldn't really like large cosmetic changes like this.
> 
> best regards,
> Michael
> 
> > -----Original Message-----
> > From: cmake-developers [mailto:cmake-developers-bounces at cmake.org]
> > On Behalf Of Robert Dailey
> > Sent: Tuesday, November 17, 2015 3:01 AM
> > To: CMake Developers
> > Subject: [cmake-developers] Code style auto-formatting
> >
> > IMHO, the code style in the CMake code base is incredibly
> > inconsistent, but even the consistent style that is there is a giant pain to
> follow by hand.
> >
> > I'm constantly fighting my tooling's auto formatting. I prefer to keep
> > my code additions similar to surrounding code. Do you use some tool
> > such as clang- format to auto format code? This will make it easier to
> > make my style more consistent after my work is completed.
> >
> > Thanks in advance.
> > --
> >
> > Powered by www.kitware.com
> >
> > Please keep messages on-topic and check the CMake FAQ at:
> > http://www.cmake.org/Wiki/CMake_FAQ
> >
> > Kitware offers various services to support the CMake community. For
> > more information on each offering, please visit:
> >
> > CMake Support: http://cmake.org/cmake/help/support.html
> > CMake Consulting: http://cmake.org/cmake/help/consulting.html
> > CMake Training Courses: http://cmake.org/cmake/help/training.html
> >
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> >
> > Follow this link to subscribe/unsubscribe:
> > http://public.kitware.com/mailman/listinfo/cmake-developers
> --
> 
> Powered by www.kitware.com
> 
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
> 
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
> 
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake-developers


More information about the cmake-developers mailing list