irccd

David Demelier 2019-08-20 Parent:c363c09e1f44 Child:d5b6dd7c2311

883:3b9603c1a1b5 Go to Latest

irccd/STYLE.md

misc: close stable-2 branch

History
1 IRC Client Daemon CODING STYLE
2 ==============================
4 General rules
5 -------------
7 - Never write two blank consecutives blank lines,
8 - No jokes,
9 - No easter eggs.
11 Style
12 -----
14 - Always use 4 spaces as indentation,
15 - Do not exceed 120 characters for lines of code,
16 - Do not exceed 80 characters for comments.
18 ### Braces
20 Braces follow the K&R style, they are never placed on their own lines except for
21 function definitions.
23 In addition to the K&R style, they are required everywhere even if a block
24 contains only one statement.
26 if (condition) {
27 apply();
28 add();
29 } else {
30 ok();
31 }
33 if (condition) {
34 validate();
35 }
37 And a lambda has its braces on the same lines too:
39 sort([&] (object&) {
40 return true;
41 });
43 ### Naming
45 - English names,
46 - Member variables starts with `m_`,
47 - No hungarian notation.
49 All functions, variables, class names are always camelCase. Only namespaces must
50 be all lowercase, short and concise. Please note that you should not create a
51 new namespace except irccd and anonymous ones.
53 int m_variable;
55 void myFunction()
56 {
57 }
59 ### Files
61 - Use `.cpp` and `.hpp` as file extensions,
62 - Filenames are all lowercase.
64 ### Comments
66 Avoid useless comments in source files. Comment complex things or why it is done
67 like this. However any public function in the .hpp **must** be documented as
68 doxygen without exception.
70 /*
71 * Multi line comments look like
72 * this.
73 */
75 // Short comment
77 ### Includes
79 The includes should always come in the following order.
81 1. C++ headers
82 2. C header
83 3. Third party libraries
84 4. Application headers in ""
86 #include <cstring>
87 #include <cerrno>
89 #include <sys/stat.h>
91 #include <libircclient.h>
93 #include "foo.h"
95 **Note**: always use C++ headers for C equivalent, stdio.h -> cstdio, etc.
97 ### Commit messages
99 Commit messages are written using the following syntax:
101 Topic: short message less than 80 characters
103 Optional additional description if needed.
105 Replace `Topic` with one of the following:
107 - **CMake**: for the build system,
108 - **Docs**: for the documentation,
109 - **Irccd**: for the `irccd(1)` daemon,
110 - **Irccdctl**: for the `irccdctl(1)` utility,
111 - **Misc**: for miscellaneous files,
112 - **Tests**: for the unit tests,
113 - **Plugin xyz**: for a specific plugin (e.g. Plugin hangman:).