diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2017-01-10 11:58:27 -0800 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2017-01-10 11:58:27 -0800 |
commit | 74994c6577a7ea129106e1ef0d5e30d87ca0499c (patch) | |
tree | ad2702decab71a573c99f5f4d2de1bb2e027ef87 /doc | |
parent | 5754e0341b7c033d4caf99534aca47e9981bd7ed (diff) |
Improve style w.r.t. if
Diffstat (limited to 'doc')
-rw-r--r-- | doc/developer-notes.md | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/doc/developer-notes.md b/doc/developer-notes.md index ba03579e86..f8c34e060f 100644 --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -11,9 +11,13 @@ gradually. - Braces on new lines for namespaces, classes, functions, methods. - Braces on the same line for everything else. - 4 space indentation (no tabs) for every block except namespaces. - - No indentation for public/protected/private or for namespaces. + - No indentation for `public`/`protected`/`private` or for `namespace`. - No extra spaces inside parenthesis; don't do ( this ) - - No space after function names; one space after if, for and while. + - No space after function names; one space after `if`, `for` and `while`. + - If an `if` only has a single-statement then-clause, it can appear + on the same line as the if, without braces. In every other case, + braces are required, and the then and else clauses must appear + correctly indented on a new line. - `++i` is preferred over `i++`. Block style example: @@ -22,14 +26,18 @@ namespace foo { class Class { - bool Function(char* psz, int n) + bool Function(const std::string& s, int n) { // Comment summarising what this section of code does for (int i = 0; i < n; ++i) { // When something fails, return early - if (!Something()) - return false; + if (!Something()) return false; ... + if (SomethingElse()) { + DoMore(); + } else { + DoLess(); + } } // Success return is usually at the end |