From: Efimov Alexander/AI Tools Lab/./Samsung Electronics Date: Fri, 19 Oct 2018 16:34:08 +0000 (+0300) Subject: Add else and catch Coding style rule (#1868) X-Git-Tag: nncc_backup~1502 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6c05a4f5f5825d2bc62dccf4829bbee7f465c1a2;p=platform%2Fcore%2Fml%2Fnnfw.git Add else and catch Coding style rule (#1868) Specify position of else and catch words in code Signed-off-by: Efimov Alexander --- diff --git a/contrib/nnc/doc/codestyle.rst b/contrib/nnc/doc/codestyle.rst index 5624893be..426bba844 100644 --- a/contrib/nnc/doc/codestyle.rst +++ b/contrib/nnc/doc/codestyle.rst @@ -106,7 +106,29 @@ Control flow contructions: -------------------------- - Function call should have no spaces around parentheses and have spaces after commas: **someFunc(arg1, arg2);** -- **if**, **while**, **for** should have space after reserved word: **if (cond)** **while (cond)** **for (cond)** +- **if**, **while**, **for** should have space after reserved word: **if (cond)**, **while (cond)**, **for (cond)** +- **else**, **catch** key words should be placed on the same line as closing code block brace: + +.. code-block:: c++ + + if (cond1) { + doThis(); + } else if (cond2) { + doThat(); + } else { + getConfused(); + } + +.. code-block:: c++ + + try { + doThis(); + } catch (PassException& e) { + doThat(); + } catch (OtherException& e) { + doABarrelRoll(); + } + - **switch** should always have **default** case, if all cases are checked and **default** is redundant, place **assert(false)** in it - Avoid redundant braces inside switch **case** - **case** labels should be indented by 2 spaces relative to **switch** @@ -122,7 +144,6 @@ Control flow contructions: else b = that; - .. code-block:: c++ switch(cond) {