Skip to content

Commit

Permalink
Auto-format the codebase (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
lstrojny authored Jul 26, 2023
1 parent 939d9af commit 7b6a644
Show file tree
Hide file tree
Showing 29 changed files with 6,360 additions and 5,001 deletions.
85 changes: 85 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Generated from CLion C/C++ Code Style settings
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignConsecutiveAssignments: None
AlignOperands: Align

AllowAllArgumentsOnNextLine: false
BinPackArguments: false
BinPackParameters: false
AlignAfterOpenBracket: BlockIndent
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false

AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Custom
MacroBlockBegin: "(ZEND_BEGIN_ARG_INFO(_EX)?|PHP_INI_BEGIN)"
MacroBlockEnd: "(ZEND_END_ARG_INFO|PHP_INI_END)"
Macros:
- "PHP_ME(a, b, c, d)={a, b, c, d},"
- "PHP_MALIAS(a, b, c, d, e)={a, b, c, d, e},"
- "ZEND_HASH_FOREACH_KEY_VAL(a, b, c, d)=do {"
- "ZEND_HASH_FOREACH_STR_KEY(a, b)=do {"
- "ZEND_HASH_FOREACH_STR_KEY_VAL(a, b, c)=do {"
- "ZEND_HASH_FOREACH_END=} while(true)"
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: true
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
ColumnLimit: 120
CompactNamespaces: false
IndentCaseLabels: true
IndentPPDirectives: BeforeHash
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Right
ReferenceAlignment: Right
ReflowComments: false
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 0
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 4
UseTab: Never
AlignArrayOfStructures: Left
SortIncludes: Never
IndentWrappedFunctionNames: true
InsertNewlineAtEOF: true
PenaltyReturnTypeOnItsOwnLine: 9999
PenaltyExcessCharacter: 100
18 changes: 18 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@ env:
TEST_TIMEOUT: 120

jobs:
checkstyle:
name: Check coding style
runs-on: ubuntu-22.04
steps:
- name: install clang-format
uses: myci-actions/add-deb-repo@11
with:
repo: "deb https://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main"
repo-name: llvm
keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key
install: clang-format-17

- name: Checkout
uses: actions/checkout@v3.5.3

- name: Check style
run: clang-format-17 --dry-run --Werror *.c *.h

test:
name: php-${{ matrix.php-version }} librabbitmq-${{ matrix.librabbitmq-version }} ${{ matrix.test-php-args == '-m' && 'memory leaks' || '' }}
runs-on: ${{ matrix.os }}
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ using `-Y amqp` attribute, just give a try - `tshark -i lo -Y amqp`.

> NOTE: -w provides raw packet data, not text. If you want text output you need to redirect stdout (e.g. using '>'), don't use the -w option for this.
#### Formatting

Run `./tools/dev-format.sh` to automatically format all `.c` and `.h` files. Note: this requires `clang-format` >=17.

#### Configuring a RabbitMQ server

Expand Down
Loading

0 comments on commit 7b6a644

Please sign in to comment.