[GRASS-dev] Replace GNU Indent with ClangFormat?

Anna Petrášová kratochanna at gmail.com
Mon Mar 21 10:43:26 PDT 2022


+1

On Ubuntu 20.04 LTS, there is ClangFormat 12, I suppose there will be 13 in
the upcoming 22.04 release.

Anna

On Mon, Mar 21, 2022 at 10:01 AM Nicklas Larsson via grass-dev <
grass-dev at lists.osgeo.org> wrote:

> Formatting the C and C++ code, making a consistent coding style was
> proposed for G8 [1]. Unfortunately, it didn't make it. There were attempts
> to do this [2, 3], but numerous problem arose using `util/grass_indent.sh`
> and its batch script `util/grass_indent_ALL.sh`, which are based on GNU
> Indent [4]. These problem are probably originate in the comparatively
> limited functionality and lack of active development on GNU Indent.
>
> I just filed a PR [5] with the aim to replace GNU Indent with ClangFormat
> [6] and later (separately!) make a bulk formatting of all the code. Running
> clang-format on all *.h|*.c|*.cpp (some 3000+) files goes fine without any
> issues. I have created a `.clang-format` file with the settings as close as
> possible to the ones in `grass_indent.sh` (somewhat outdated described in
> [7]).
>
> ClangFormat is a working program in active development, therefore its
> performance is version dependent (similar to what we have had with Black
> for Python). On the other hand, its adaptation is increasing, now used in
> several big and small projects.
>
>
> Now the question is first of all: is using ClangFormat something the GRASS
> dev community (you) would want or could live with for this project?
> And if so, what version of ClangFormat should then be the starting point
> (what do you have reasonably easy available for your dev platform)? The
> present settings in the PR are derived from ClangFormat 13, but could
> possibly be back ported if really needed.
>
> Please check out the settings, as well as some code files formatted for
> illustrational purposes only, at the PR [5].
>
>
> Best,
> Nicklas
>
>
>
> [1]
> https://trac.osgeo.org/grass/wiki/Grass8Planning#Codeorganisationcodingstyles
> [2] https://github.com/OSGeo/grass/issues/1630
> [3] https://github.com/OSGeo/grass/pull/2270
> [4] https://www.gnu.org/software/indent/
> [5] https://github.com/OSGeo/grass/pull/2272
> [6] https://clang.llvm.org/docs/ClangFormat.html
> [7] https://trac.osgeo.org/grass/wiki/Submitting/C#Indentation
>
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20220321/086fd342/attachment.html>


More information about the grass-dev mailing list