Add code style guidance to CONTRIBUTING (#6212)
* Add code style guidance to CONTRIBUTING * Update CONTRIBUTING.md * Update CONTRIBUTING.md
Chris Akritidis committed
Jun 4, 2019 at 15:12 UTC
6240d638d5bc8867009bbd957678842693fe25c0
1 file changed
+12
CONTRIBUTING.md
+12
@@ -120,6 +120,18 @@ Your contributions should be bundled with related documentation to help users un
120
121
When you contribute code to Netdata, you are automatically accepting that you will be responsible for maintaining that code in the future. So, if users need help, or report bugs, we will invite you to the related github issues to help them or fix the issues or bugs of your contributions.
122
123
+#### Code Style
124
+
125
+The single most important rule when writing code is this: *check the surrounding code and try to imitate it*. [Reference](https://developer.gnome.org/programming-guidelines/stable/c-coding-style.html.en)
126
+
127
+We use several different languages and have had contributions from several people with different styles. When in doubt, you can check similar existing code.
128
+
129
+For C contributions in particular, we try to respect the [Linux kernel style](https://www.kernel.org/doc/html/v4.10/process/coding-style.html), with the following exceptions:
130
+ - Use 4 space indentation instead of 8
131
+ - We occassionally have multiple statements on a single line (e.g. `if (a) b;`)
132
+ - Allow max line length of 120 chars
133
+ - Allow opening brace at the end of a function declaration: `function() {`.
134
+
135
### Your first pull request
136
137
There are several guides for pull requests, such as the following: