mirror of
https://github.com/djhackersdev/bemanitools.git
synced 2024-11-27 16:00:52 +01:00
Some clang-format tweaks to optimize code style
This commit is contained in:
parent
6741a1f2fd
commit
c600e1a423
@ -9,23 +9,23 @@ AllowShortCaseLabelsOnASingleLine: 'false'
|
|||||||
AllowShortFunctionsOnASingleLine: None
|
AllowShortFunctionsOnASingleLine: None
|
||||||
AllowShortIfStatementsOnASingleLine: 'false'
|
AllowShortIfStatementsOnASingleLine: 'false'
|
||||||
AllowShortLoopsOnASingleLine: 'false'
|
AllowShortLoopsOnASingleLine: 'false'
|
||||||
AlwaysBreakAfterDefinitionReturnType: All
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
AlwaysBreakAfterReturnType: None
|
AlwaysBreakAfterReturnType: None
|
||||||
AlwaysBreakBeforeMultilineStrings: 'false'
|
AlwaysBreakBeforeMultilineStrings: 'true'
|
||||||
BinPackArguments: 'false'
|
BinPackArguments: 'false'
|
||||||
BinPackParameters: 'false'
|
BinPackParameters: 'false'
|
||||||
BreakBeforeBinaryOperators: None
|
BreakBeforeBinaryOperators: None
|
||||||
BreakBeforeBraces: Linux
|
BreakBeforeBraces: Linux
|
||||||
BreakBeforeTernaryOperators: 'false'
|
BreakBeforeTernaryOperators: 'false'
|
||||||
BreakStringLiterals: 'true'
|
BreakStringLiterals: 'true'
|
||||||
ColumnLimit: '120'
|
ColumnLimit: '80'
|
||||||
ContinuationIndentWidth: '8'
|
ContinuationIndentWidth: '4'
|
||||||
IncludeBlocks: Preserve
|
IncludeBlocks: Preserve
|
||||||
IndentCaseLabels: 'false'
|
IndentCaseLabels: 'true'
|
||||||
IndentPPDirectives: None
|
IndentPPDirectives: None
|
||||||
IndentWidth: '4'
|
IndentWidth: '4'
|
||||||
IndentWrappedFunctionNames: 'false'
|
IndentWrappedFunctionNames: 'false'
|
||||||
KeepEmptyLinesAtTheStartOfBlocks: 'false'
|
KeepEmptyLinesAtTheStartOfBlocks: 'true'
|
||||||
Language: Cpp
|
Language: Cpp
|
||||||
MaxEmptyLinesToKeep: '1'
|
MaxEmptyLinesToKeep: '1'
|
||||||
PointerAlignment: Right
|
PointerAlignment: Right
|
||||||
|
@ -160,6 +160,26 @@ if (var == 2) {
|
|||||||
printf("%d\n", var);
|
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
|
#### Includes
|
||||||
* Always keep all includes at the top of a header and source file. Exception: Documentation before include guards on
|
* Always keep all includes at the top of a header and source file. Exception: Documentation before include guards on
|
||||||
header file.
|
header file.
|
||||||
@ -311,6 +331,20 @@ Upper-case with underscore as spacing, proper namespacing to namespace and modul
|
|||||||
#define EZUSB_DEVICE_VID 0xFFFF
|
#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
|
### Testing
|
||||||
We advice you to write unit tests for all modules that allow proper unit testing. This applies to modules that are not
|
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
|
part of the actual hooking process and do not rely on external devices to be available. Add these tests to the
|
||||||
|
Loading…
Reference in New Issue
Block a user