Code should be understandable. To be able to understand code, it must be readable. In order to be readable, it must be properly formatted.
We use a tool called clang-format to reformat code, which applies the style defined in .clang-format. Starting with PR#291, continuous integration will check modified files for proper formatting. The intent is to slowly get the whole project formatted without too much inconvenience.
Please run clang-format on all .C, *.cpp, *.cxx, and *.h files touched in your commit. Use travis-clang-format-check.sh to check if your commit is acceptable before submitting your pull request. The formatting can be applied manually to change the file in-place:
clang-format -i file.cxx
You can exclude code by using "// clang-format off" and "// clang-format off" where the automatic produces sub-optimal results. For example each *LinkDef.h file should have // clang-format off at the top.
There are also tools to integrate it into all reasonable editors and IDEs, e.g.:
- Clion https://www.jetbrains.com/help/clion/clangformat-as-alternative-formatter.html - VisualStudio Code https://marketplace.visualstudio.com/items?itemName=xaver.clang-format - Sublime Text https://packagecontrol.io/packages/Clang%20Format - Vim https://github.com/rhysd/vim-clang-format