From eb7601d116e0ccbdf5dfaa62aba7ef9bc20fa761 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Niemier?= Date: Sun, 18 Nov 2012 13:39:37 +0100 Subject: [PATCH] Add styleguide --- STYLEGUIDE.md | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 STYLEGUIDE.md diff --git a/STYLEGUIDE.md b/STYLEGUIDE.md new file mode 100644 index 000000000..dd304b3d3 --- /dev/null +++ b/STYLEGUIDE.md @@ -0,0 +1,101 @@ +# Style guide + +This is style guide for fish contributors. You should use it for any new code +that you would add to this project and try to format existing code to use this +style. + +## Formatting + +1. Always use 2 spaces instead tabs as indent (unless needed like `Makefile`). +2. Opening curly bracket is always the same line as declaration. + + // ✔: + struct name { + // code + }; + + void func() { + // code + } + + if (...) { + // code + } + + // ✗: + void func() + { + // code + } + +3. Put space after `if`, `while` and `for` before conditions. + + // ✔: + if () {} + + // ✗: + if() {} + +4. Put spaces before and after operators excluding increment and decrement; + + // ✔: + int a = 1 + 2 * 3; + a++; + + // ✗: + int a=1+2*3; + a ++; + +5. Never put spaces between function name and parameters list. + + // ✔: + func(args); + + // ✗: + func (args); + +6. Never put spaces after `(` and before `)`. +7. Always put space after comma and semicolon. + + // ✔: + func(arg1, arg2); + + for (int i = 0; i < LENGTH; i++) {} + + // ✗: + func(arg1,arg2); + + for (int i = 0;i