This page documents how static analysis and autoformatting tools can be used to enforce the Zubax C++ coding conventions.
Unlike AStyle or Uncrustify, clang-format doesn't tend to break your code or introduce nonsensical changes, so it is the recommended option. The configuration file below requires clang-format version 8 or newer. Note that clang-format can't enforce brace placement and some other things; consider using clang-tidy for that.
Put the config file in the sources' root directory, then run from the same directory:
Enforce a consistent coding style using CI by running clang-format against a fresh working copy, and then ask git if there were any changes introduced. If there are no changes, the codebase is conforming, otherwise it's not and the build should be failed.
Clang-Tidy can be used to enforce some of the MISRA rules. A compliant configuration is provided below; the provided configuration, however, is still a work-in-progress, so use with care.
Eclipse IDE autoformatter
Configuration file for the Eclipse autoformatter is attached below. Eclipse's embedded autoformatter is quite limited in its capabilities and tends to break complex C++ code, so one should not rely on it too much. New projects are recommended to use JetBrains CLion instead.