[gdal-dev] Automating code style enforcement ?

Kurt Schwehr schwehr at gmail.com
Fri May 5 11:04:24 PDT 2017


astyle would certainly work too.

I find clang-format more robust than almost all other formatting tools as
Mateusz described.  As for workflow, there are multiple possible routes as
to how to go about this.  I personally write pretty messy code when I'm
working and then just do a format pass before submitting.  If the editor
I'm using supports formatting, great.  However, the command line is super
easy.  I also know a number of people who work on code only after applying
their own person clang format style to code and then transform back before
submitting.  And there is the critical ability to shut off the formatter
for sections of code where the formatter will do something seriously
wrong... the classic example is matrices in test files.

Alternatively, we could easily have astyle as a first pass to add braces
before clang-format if someone wanted to implement that.  But there
clang-tidy as Mateusz said with:

https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html

with lots of other check....

https://clang.llvm.org/extra/clang-tidy/checks/list.html

On Fri, May 5, 2017 at 4:46 AM, Mateusz Loskot <mateusz at loskot.net> wrote:

> On 5 May 2017 at 13:35, Even Rouault <even.rouault at spatialys.com> wrote:
> >
> > In case we want to have a policy regarding braces around single
> statements,
> > one finding coming from the openjpeg discussion I mentionned :
> >
> > """
> > Moreover, concerning braces around single statements, it seems astyle
> does
> > this with the add-braces option:
> > http://astyle.sourceforge.net/astyle.html#_add-braces
> > As far as I understood, clang-format does not, and requires another tool
> > (clang-tidy) to deal with these cases. So one more point for astyle.
> > """
>
> Rather, it is a separation of concerns: linting vs formatting
> AFAIU, clang-format does not modify any code (ie. add tokens).
>
> I'm not clang-format advocate. I'll repeat myself:
> My personal preference is to use clang-format.
> I proposed it to GEOS via GEOS RFC.
> Kurt found the RFC useful and is using it as a template
> to prepare one for GDAL.
> IMHO, at the end of the day, tool does not matter as long as proposed
> goals are achieved.
>
> Best regards,
> --
> Mateusz Loskot, http://mateusz.loskot.net
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>



-- 
--
http://schwehr.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20170505/60f3e828/attachment.html>


More information about the gdal-dev mailing list