[postgis-devel] Code formatting digging in

Darafei "Komяpa" Praliaskouski me at komzpa.net
Thu Feb 22 10:57:34 PST 2018


Hi,

Two things are crucial about clang-format:
1. clang-format is part of clang/llvm, so it's reusing parts of the same
engine that parses the code on compilation;
2. clang-format ships git-clang-format that is able to format just a patch.

Even if committer has different clang-format version, if they use
git-clang-format they'll change only the lines they would have edited
anyway, so that situation with someone having incompatible version is not
making things worse. In that it's majorly different from astyle way from
years ago when it was a complete project reformat on every commit.

In PR Raul mentioned I'm reformatting all the code, but it doesn't have to
be done in one go - I mostly wanted to test it's producing sane compiling
output.

Minimal change is dragging in .clang-format from that PR and start
routinely using it on commits.
Although I tried to match the lwgeom part's style, if we're adopting one of
LLVM's supported ones we'll have a benefit of good existing testing
coverage and familiarity to developers.
Here's the list:
https://clang.llvm.org/docs/ClangFormatStyleOptions.html#configurable-format-style-options

Default, LLVM internal, one seems already much like the raster part - this
way we don't need to store .clang-format file:
https://llvm.org/docs/CodingStandards.html

PostGIS lived without formatting for 8 years, so either formatter would
have to format more than several tens of thousands lines if applied in one
go, especially there are three distinct formatting styles already.

Sandro, are you looking on numbers from formatting just *.c files or *.c
and *.h files?

чт, 22 февр. 2018 г. в 21:37, Sandro Santilli <strk at kbt.io>:

> On Thu, Feb 22, 2018 at 07:05:14PM +0100, Sandro Santilli wrote:
>
> > QGIS (to look at close neighbours) used to ship their own version
> > of astyle to deal with it. Recently they introduced again ability
> > to use the system astyle, do we want to try that again ?
> >
> https://github.com/qgis/qgis/commit/c48e0069aee5360f71d3128a1f3c14775b7fb491
> >
> > QGIS now requires astyle 3.0+
>
> Just to give more info: the version of astyle that QGIS ships
> is 3.1, they just embed the full source code in qgis codebase.
>
> It only takes 664K:
>
>   664K    external/astyle/
>
> That'd be ~1% of the current PostGIS source code.
> I would not be against doing the same.
>
> --strk;
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20180222/1e2fccfc/attachment.html>


More information about the postgis-devel mailing list