Skip to content

docs: Add styleguide.

Felix Weiglhofer requested to merge fweig/cbmroot:styleguide into master

Adds styleguide document. I added links to the ALICE styleguide and outlined the changes / exceptions we agreed on.

Additionally some adjustments to clang-format:

  • AccessModifierOffset: -1: Indent access specifier by 1 space. For consistency with ALICE. Not sure this change is necessary. ALICE also formats class brackets differently. And on it's own I don't see any benefit over the current format.
  • AllowShortBlocksOnASingleLine: Never + AllowShortIfStatementsOnASingleLine: Never Enforces line break after if. So allowed formattings are now:
if (someTest)
  foo();

and

if (someTest) {
  foo();
}

Again this is now identical to ALICE. Changes we discussed to always add the brackets isn't possible with our version of clang-format.

  • Not discussed during the meeting:
  - Regex:          '".*"'
    Priority:        1

This should only affect online code. Puts includes from within cbmroot (included via "") before external includes (that should be included via <>). This is necessary because online code drops the Cbm prefix from file names that is used to distinguish cbmroot headers.

  • SpaceBeforeCpp11BracedList: false: ALICE styleguide recommends using brace initialization.
std::vector<std::string> myVector {"alpha", "beta", "gamma"};
// becomes
std::vector<std::string> myVector{"alpha", "beta", "gamma"};

This unifies initialization for c structs and c++ classes.

Requesting feedback from: @p.-a.loizeau, @d.smith, @j.decuveland, @s.zharko, @se.gorbunov, @f.uhlig, @v.friese

Edited by Felix Weiglhofer

Merge request reports