Reformat the code using clang-format
This is a proposal to add clang-format to our automatic toolchain. The automatic reformatting is not perfect but I am fine with it.
The scripts are based on a work by Alexander Müller, what he proposed for the dune-tensor repo.
Merge request reports
Activity
mentioned in merge request !4 (merged)
Closed in favor of !4 (merged)
At that point I was not aware of the difficulties with uncrustify. It was used in other repos already and proposed for dune-common so I though, it might be the easiest choice. Also it allows to ignore several formatting rules. Not sure yet, how to configure this in clang-format. Also, I don't know whether we will have the same problem. The clang-format options also evolve and change over versions. Maybe it is at least consistent in its formatting when using an older options file.
A BIG advantage of clang-format is that it is properly documented and uses properly named options keys. uncrustify is only rarely documented. This is even written in the uncrustify
--help
message:There are currently 850 options and minimal documentation. Try UniversalIndentGUI and good luck.
Note that
UniversalIndentGUI
is already outdated since 2012 and does not compile anymore.
I just found the python tool whatstyle (https://pypi.org/project/whatstyle/) that tries to figure out a config file that represents a given source style. This could also be done for clang. Maybe I let this run on a file we have formatted using uncrustify to get a similar clang-format (just as an experiment)