From 581722d41f566ba87ed716484d73c22ea8586d87 Mon Sep 17 00:00:00 2001
From: Giulio Eulisse General guideline
Example of a typical class definition within a project and
sub-project namespace:
-
namespace project::subproject
+{
+
+class MyClass
+{
+...
+};
+
+} // namespace subproject::projectAlternatively, the C++98/11/14 style for nested namespaces can be used:
namespace project
{
namespace subproject
From 14b25480af1bfb7dce121424b7fc3852bcbf7809 Mon Sep 17 00:00:00 2001
From: Laurent Aphecetche
Date: Tue, 23 Apr 2019 17:38:26 +0200
Subject: [PATCH 15/27] Add a rule for executable names
---
naming_formatting.html | 40 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
diff --git a/naming_formatting.html b/naming_formatting.html
index adbc44e..5ea9f6b 100644
--- a/naming_formatting.html
+++ b/naming_formatting.html
@@ -172,7 +172,18 @@ ALICE O² C++ Naming & Formatting Rules
+ General Naming Rules
+ File Names
+ Executable Names
+ Type Names
+ Interface Names
+ Variable Names
+ Function Names
+ Namespace Names
+ Enumerator Names
+ Macro Names
+
+
@@ -373,6 +384,33 @@ File Names
+
+
+ Executable Names
+
+
+
+
+ Executable names should be in lowercase, prefixed with o2, and hyphenated : o2-tpc-reco-workflow
+
+
+
+
+
+
+
+
+ Library Names
+
+
+
+
+ Library names should follow camel case convention (with the exception of the subsystem names) and be prefixed with O2.
+
+
+
+
+
+
+
+
+ Executable Names
+
+
+
+
+ Executable names should be in lowercase, prefixed with o2, and hyphenated : o2-tpc-reco-workflow
+
-
- Executable Names
-
-
-
-
- Executable names should be in lowercase, prefixed with o2, and hyphenated : o2-tpc-reco-workflow
-
-
-
+
-
+
+
+
+
+ Library Names
+
+
+
+
+ Library names should follow camel case convention (with the exception of the subsystem names) and be prefixed with
+ O2.
+
-
- Library Names
-
-
-
-
- Library names should follow camel case convention (with the exception of the subsystem names) and be prefixed with O2.
-
-
-
+
+
+
Type Names
From 12a68c6021a8cfbf0e17fa706247b12253703a28 Mon Sep 17 00:00:00 2001
From: Barthelemy
Date: Fri, 19 Jul 2019 17:12:05 +0200
Subject: [PATCH 19/27] File Name -> Code File Name
---
naming_formatting.html | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/naming_formatting.html b/naming_formatting.html
index 1aa20ac..f20c49e 100644
--- a/naming_formatting.html
+++ b/naming_formatting.html
@@ -173,7 +173,7 @@ ALICE O² C++ Naming & Formatting Rules
General Naming Rules
- File Names
+ Code File Names
Executable Names
Library Names
Type Names
@@ -343,7 +343,7 @@ General Naming Rule
-File Names
+Code File Names
From 6fe9fc780b4cd868b2fe3f007781df20f647601c Mon Sep 17 00:00:00 2001
From: Barthelemy
Date: Wed, 9 Oct 2019 14:53:14 +0200
Subject: [PATCH 20/27] Acronyms can be capitalized
---
naming_formatting.html | 2 ++
1 file changed, 2 insertions(+)
diff --git a/naming_formatting.html b/naming_formatting.html
index f20c49e..7c6d69f 100644
--- a/naming_formatting.html
+++ b/naming_formatting.html
@@ -288,11 +288,13 @@ General Naming Rule
All names in C++ code follow camel case convention. This is
the practice of writing compound words so that each word
begins with a capital letter. No underscores are allowed.
+ Acronyms are the only exception : they can be capitalized.
For example:
string tableName; // Good
+ class ITSReco // Good, acronyms can be capitalized
string table_name; // Bad - uses underscore.
string tablename; // Bad - all lowercase.
From 793aff43b8d670534581a0414935758ffb803c77 Mon Sep 17 00:00:00 2001
From: Sandro Wenzel
Date: Mon, 28 Sep 2020 09:43:46 +0200
Subject: [PATCH 21/27] Consistency fix for namespace rules
---
naming_formatting.html | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/naming_formatting.html b/naming_formatting.html
index 7c6d69f..84f07ab 100644
--- a/naming_formatting.html
+++ b/naming_formatting.html
@@ -303,7 +303,7 @@ General Naming Rule
Capitalization Rules
Variables and functions start with a lowercase letter.
- Everything else in C++ code (namespaces, type names, constant
+ Everything else in C++ code (type names, constant
expressions) starts with an uppercase letter.
@@ -1145,9 +1145,9 @@ Namespaces
When declaring nested namespaces, put each namespace on its own line.
- namespace Foo
+ namespace foo
{
-namespace Bar
+namespace bar
{
...
}
From bdf27980835f23477dcfeb527ae377cbd1769a32 Mon Sep 17 00:00:00 2001
From: David Rohr
Date: Fri, 5 Feb 2021 12:10:28 +0100
Subject: [PATCH 22/27] Clarify difference between clang-format and
git-clang-format
---
README.md | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/README.md b/README.md
index 5e0f73b..f3457ae 100644
--- a/README.md
+++ b/README.md
@@ -37,7 +37,20 @@ wget llvm.org/svn/llvm-project/cfe/trunk/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
+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
@@ -59,18 +72,6 @@ Display what needs to be fixed in a file :
clang-format -style=file | diff -
```
-#### 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
-```
-
#### Using an IDE
A number of config files are available [here](https://github.com/AliceO2Group/CodingGuidelines) for various IDEs.
From c93b6af2c221821a2c8c59907f639f3ede71badd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=ADt=20Ku=C4=8Dera?=
Date: Tue, 2 Mar 2021 14:18:29 +0100
Subject: [PATCH 23/27] Fix link to git-clang-format.
---
README.md | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/README.md b/README.md
index f3457ae..b3782e5 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ Coding guidelines for the ALICE O2 project.
* [Comments guidelines](https://rawgit.com/AliceO2Group/CodingGuidelines/master/comments_guidelines.html)
### Formatting tool
-The ALICE O2 projects use `clang-format` to push for a common code formatting. The rules are defined in
+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
@@ -18,7 +18,7 @@ changed lines.
#### Install `clang-format` and git integration
-Note : The installation of clang using aliBuild is not necessary on Mac.
+Note : The installation of clang using aliBuild is not necessary on Mac.
1. Build clang (to be done once)
```bash
@@ -33,7 +33,7 @@ alienv enter Clang/latest
cd $HOME
mkdir -p bin
cd bin
-wget llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/git-clang-format
+wget https://raw.githubusercontent.com/llvm/llvm-project/main/clang/tools/clang-format/git-clang-format
chmod u+x git-clang-format
```
@@ -61,13 +61,13 @@ 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) :
+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
+find . -iname "*.h" -o -iname "*.cpp" | xargs clang-format -style=file -i
```
-Display what needs to be fixed in a file :
+Display what needs to be fixed in a file :
```
clang-format -style=file | diff -
```
@@ -80,9 +80,9 @@ A number of config files are available [here](https://github.com/AliceO2Group/Co
#### CLion
1. [Download](https://github.com/AliceO2Group/CodingGuidelines/raw/master/settings-o2-codestyle-clion.jar),
-2. Go to File -> Import Settings.
+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.
-
+
From e72f0d2ec8e24f48e68ef0f94077c2881f8c1d56 Mon Sep 17 00:00:00 2001
From: sy-c
Date: Wed, 23 Jun 2021 09:59:03 +0200
Subject: [PATCH 24/27] Update README.md (#23)
Specify that commands rely on .clang-format file.
---
README.md | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/README.md b/README.md
index b3782e5..61f0f3a 100644
--- a/README.md
+++ b/README.md
@@ -50,7 +50,12 @@ git clang-format origin/dev
```
#### Check files' formatting
+
+The commands below rely on the [.clang-format](.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
From 2593120848ba715ea9f9701c402036d308b949b9 Mon Sep 17 00:00:00 2001
From: David Rohr
Date: Tue, 22 Jun 2021 13:30:31 +0200
Subject: [PATCH 25/27] Update exception policy
---
coding_guidelines.html | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/coding_guidelines.html b/coding_guidelines.html
index 79720fc..88595d8 100644
--- a/coding_guidelines.html
+++ b/coding_guidelines.html
@@ -1897,13 +1897,18 @@ Exceptions
link
- Use C++ exceptions instead of return codes for error handling. Do not use exceptions to return values.
+ C++ exceptions can be used for error handling in non-performance-relevant code, like context initialization running only once during the lifetime of the program.
+ Usually return values shall be used.