Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ihrivnac/CodingGuidelines

Open more actions menu
 
 

Repository files navigation

JIRA

ALICE O2 Coding Guidelines

Coding guidelines for the ALICE O2 project.

Documents

Formatting tool

The ALICE O2 projects use clang-format to push for a common code formatting. The rules are defined in the clang-format configuration file in this repository (which is propagated to other AliceO2Group repositories). With an adiabatic approach, all changes have to follow the formatting rules. A script, described below, can be used to integrate the formatting into git and suggest formatting only for changed lines.

Install clang-format and git integration

Note : The installation of clang using aliBuild is not necessary on Mac.

  1. Build clang (to be done once)
aliBuild build --defaults o2 Clang
  1. Load clang and clang-format
alienv enter Clang/latest
  1. Install git-clang-format
cd $HOME
mkdir -p bin
cd bin
wget https://raw.githubusercontent.com/llvm/llvm-project/main/clang/tools/clang-format/git-clang-format
chmod u+x git-clang-format

Check commits' formatting

git clang-format invokes clang-format on the changes in current files or a specific commit. E.g. for the last commit

git clang-format HEAD~1

Or for all commits done with respect to the remote branch state

git clang-format origin/dev

Check files' formatting

The commands below rely on the .clang-format file located in one of the parent directories of the source files.

Please note that for technical reasons, there are slight differences between clang-format and git-clang-format (see above). All pull requests are checked with git-clang-format as described in the previous bullet. Thus make sure that before pushing code, correct the formatting with git-clang-format. The instructions for clang-format are left here only for reference.

Show correctly formatted version of a file :

clang-format -style=file SOURCEFILE

Directly apply the style to a file :

clang-format -style=file -i SOURCEFILE

Apply the style to all the source and header files in a directory (recursive) :

find . -iname "*.h" -o -iname "*.cpp" | xargs clang-format -style=file -i

Display what needs to be fixed in a file :

clang-format -style=file <SOURCEFILE> | diff <SOURCEFILE> -

Using an IDE

A number of config files are available here for various IDEs.

Configuration files for editors

CLion

  1. Download,
  2. Go to File -> Import Settings.

FAQ

  • Q I strongly disagree with rule X !
  • A Feel free to contact the WP3 (alice-o2-wp3@cern.ch) to share your concern(s). Rules have already been amended, abandoned or added based on the users feedback. However, please comply with the rules until a change is agreed by CWG11.

About

Coding guidelines for the ALICE O2 project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 98.0%
  • CSS 2.0%
Morty Proxy This is a proxified and sanitized view of the page, visit original site.