mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-12-24 19:37:48 +03: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
|
||||
BasedOnStyle: LLVM
|
||||
IndentWidth: 4
|
||||
@@ -13,6 +14,7 @@ BraceWrapping:
|
||||
BeforeElse: false
|
||||
BeforeWhile: false
|
||||
IndentCaseLabels: false
|
||||
IndentCaseBlocks: false
|
||||
ColumnLimit: 80
|
||||
AlignAfterOpenBracket: Align
|
||||
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
|
||||
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!
|
||||
|
||||
|
||||
Reference in New Issue
Block a user