comparison STYLE.md @ 409:c363c09e1f44

Misc: add CONTRIBUTE.md and STYLE.md
author David Demelier <markand@malikania.fr>
date Wed, 25 Jan 2017 13:29:11 +0100
parents
children d5b6dd7c2311
comparison
equal deleted inserted replaced
408:35c40ac0dc26 409:c363c09e1f44
1 IRC Client Daemon CODING STYLE
2 ==============================
3
4 General rules
5 -------------
6
7 - Never write two blank consecutives blank lines,
8 - No jokes,
9 - No easter eggs.
10
11 Style
12 -----
13
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.
17
18 ### Braces
19
20 Braces follow the K&R style, they are never placed on their own lines except for
21 function definitions.
22
23 In addition to the K&R style, they are required everywhere even if a block
24 contains only one statement.
25
26 if (condition) {
27 apply();
28 add();
29 } else {
30 ok();
31 }
32
33 if (condition) {
34 validate();
35 }
36
37 And a lambda has its braces on the same lines too:
38
39 sort([&] (object&) {
40 return true;
41 });
42
43 ### Naming
44
45 - English names,
46 - Member variables starts with `m_`,
47 - No hungarian notation.
48
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.
52
53 int m_variable;
54
55 void myFunction()
56 {
57 }
58
59 ### Files
60
61 - Use `.cpp` and `.hpp` as file extensions,
62 - Filenames are all lowercase.
63
64 ### Comments
65
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.
69
70 /*
71 * Multi line comments look like
72 * this.
73 */
74
75 // Short comment
76
77 ### Includes
78
79 The includes should always come in the following order.
80
81 1. C++ headers
82 2. C header
83 3. Third party libraries
84 4. Application headers in ""
85
86 #include <cstring>
87 #include <cerrno>
88
89 #include <sys/stat.h>
90
91 #include <libircclient.h>
92
93 #include "foo.h"
94
95 **Note**: always use C++ headers for C equivalent, stdio.h -> cstdio, etc.
96
97 ### Commit messages
98
99 Commit messages are written using the following syntax:
100
101 Topic: short message less than 80 characters
102
103 Optional additional description if needed.
104
105 Replace `Topic` with one of the following:
106
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:).