1
0
mirror of https://github.com/djhackersdev/bemanitools.git synced 2024-09-23 18:38:22 +02:00

Some clang-format tweaks to optimize code style

This commit is contained in:
icex2 2019-10-19 23:47:27 +02:00
parent 6741a1f2fd
commit c600e1a423
2 changed files with 40 additions and 6 deletions

View File

@ -9,23 +9,23 @@ AllowShortCaseLabelsOnASingleLine: 'false'
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: 'false'
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakAfterDefinitionReturnType: All
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: 'false'
AlwaysBreakBeforeMultilineStrings: 'true'
BinPackArguments: 'false'
BinPackParameters: 'false'
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Linux
BreakBeforeTernaryOperators: 'false'
BreakStringLiterals: 'true'
ColumnLimit: '120'
ContinuationIndentWidth: '8'
ColumnLimit: '80'
ContinuationIndentWidth: '4'
IncludeBlocks: Preserve
IndentCaseLabels: 'false'
IndentCaseLabels: 'true'
IndentPPDirectives: None
IndentWidth: '4'
IndentWrappedFunctionNames: 'false'
KeepEmptyLinesAtTheStartOfBlocks: 'false'
KeepEmptyLinesAtTheStartOfBlocks: 'true'
Language: Cpp
MaxEmptyLinesToKeep: '1'
PointerAlignment: Right

View File

@ -160,6 +160,26 @@ if (var == 2) {
printf("%d\n", var);
```
#### Empty line at the start of blocks
There are situations when you want to have an empty line at the start of the block to enhance readability, for example:
```
if (a &&
b &&
c) {
d = 5;
}
```
Here the assignment aligns with the conditions of the if-black making it hard to read. Better:
```
if (a &&
b &&
c) {
d = 5;
}
```
#### Includes
* Always keep all includes at the top of a header and source file. Exception: Documentation before include guards on
header file.
@ -311,6 +331,20 @@ Upper-case with underscore as spacing, proper namespacing to namespace and modul
#define EZUSB_DEVICE_VID 0xFFFF
```
#### Multiple variable declarations
Only one declaration per line which also avoids various errors, for example:
```
// Nope
char a, b, b;
```
```
// Ok
char a;
char b;
char c;
```
### Testing
We advice you to write unit tests for all modules that allow proper unit testing. This applies to modules that are not
part of the actual hooking process and do not rely on external devices to be available. Add these tests to the