mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-10 10:26:47 +09:00
CONTRIBUTING: Do not indent case labels nor blocks
Fixes: #188 Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
6a965e0981
commit
4d98390678
@@ -1,3 +1,4 @@
|
|||||||
|
---
|
||||||
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
|
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
|
||||||
BasedOnStyle: LLVM
|
BasedOnStyle: LLVM
|
||||||
IndentWidth: 4
|
IndentWidth: 4
|
||||||
@@ -13,6 +14,7 @@ BraceWrapping:
|
|||||||
BeforeElse: false
|
BeforeElse: false
|
||||||
BeforeWhile: false
|
BeforeWhile: false
|
||||||
IndentCaseLabels: false
|
IndentCaseLabels: false
|
||||||
|
IndentCaseBlocks: false
|
||||||
ColumnLimit: 80
|
ColumnLimit: 80
|
||||||
AlignAfterOpenBracket: Align
|
AlignAfterOpenBracket: Align
|
||||||
AllowAllParametersOfDeclarationOnNextLine: false
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
|
|||||||
@@ -478,6 +478,45 @@ Macros like `STATUS_NOT_OK_RETURN` that change control flow (return/goto/etc)
|
|||||||
from within the macro are considered bad, because they look like function calls
|
from within the macro are considered bad, because they look like function calls
|
||||||
that never change control flow. Please do not introduce them.
|
that never change control flow. Please do not introduce them.
|
||||||
|
|
||||||
|
### Switch/case indentation
|
||||||
|
|
||||||
|
The `case` should not be indented to avoid wasting too much horizontal space.
|
||||||
|
When the case block contains local variables that need to be wrapped in braces,
|
||||||
|
they should not be indented again either.
|
||||||
|
|
||||||
|
Good example:
|
||||||
|
|
||||||
|
switch (x) {
|
||||||
|
case 0:
|
||||||
|
do_stuff();
|
||||||
|
break;
|
||||||
|
case 1: {
|
||||||
|
int y;
|
||||||
|
do_stuff();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
do_other_stuff();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bad example:
|
||||||
|
|
||||||
|
switch (x) {
|
||||||
|
case 0:
|
||||||
|
do_stuff();
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
int y;
|
||||||
|
do_stuff();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
do_other_stuff();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Have fun and happy libssh hacking!
|
Have fun and happy libssh hacking!
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user