[gdal-dev] Clang-format

Even Rouault even.rouault at spatialys.com
Sat Oct 10 14:39:23 PDT 2020


Hi,

> I am trying to make a PR ready for release 3.2 (let's see if I am able to
> do it).
> However, I found it strange that there is no automatic formatting with
> clang-format for C++ code.
> 
> In this page
> https://gdal.org/development/rfc/rfc69_cplusplus_formatting.html it is
> suggesting to use it. That would be great! Enabling it in your favourite
> editor makes the code nicer, without any extra work. And more consistent!
> 
> About "when" to apply it (reformatting *all* the existing code), I think a
> good moment could be just before creating a "big" release branch, like 3.2.
> Then the backport of bug fixes would be easy (otherwise it is a nightmare).
> 
> What do you think?

Was discussed at that time in
https://lists.osgeo.org/pipermail/gdal-dev/2017-May/thread.html#46560

I would be quite in favor of the principle
A few points I've in mind:
- I'm slightly worried about clang-format output changing between versions of the tool 
(based on my experience with PROJ, I can tell you that they are different between 3.8, which 
is the one we used for PROJ, and 10), which would be an issue as we cannot be certain that 
our set of contributors to have different versions. Not sure if having a custom .clang-format 
file (possibly a 'standard' one that we put in our tree to make output stable) would help ? This 
would have to be investigated & tested.
- We'd have to exclude some files from the reformatting, in particular third-party libraries 
that we import in the GDAL tree (libjpeg, libtiff, libpng, libjson-c, libcsf, degrib, g2clib ...)
- We'd need a scripts/prepare-commit.sh style of script like QGIS to be able to automatically 
reformat files that are in modified state according to git according to the formatting rules
- We'd need a CI test like QGIS to reject pull requests that don't match the formating rules, 
and with nice hint on what's wrong and how to fix it
- The reformatting would have to be done from a dedicated github account
- And someone to implement that

Even


-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20201010/2150c83a/attachment.html>


More information about the gdal-dev mailing list