Skip to content

Commit 9634977

Browse files
authored
[WIP] auto code-format bot (#849)
* Create code-format.yml * trigger on push only * Update code-format.yml * apply code-format changes
1 parent 1fa06fd commit 9634977

File tree

820 files changed

+28221
-29759
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

820 files changed

+28221
-29759
lines changed

.clang-format

+130-168
Original file line numberDiff line numberDiff line change
@@ -1,170 +1,132 @@
1-
Language: Cpp
2-
3-
AccessModifierOffset: -4
4-
5-
AlignAfterOpenBracket: Align
6-
AlignConsecutiveAssignments: AcrossEmptyLines
7-
AlignConsecutiveBitFields: AcrossEmptyLinesAndComments
8-
AlignConsecutiveDeclarations: Consecutive
9-
AlignConsecutiveMacros: AcrossEmptyLines
10-
AlignEscapedNewlines: Right
11-
AlignOperands: true
12-
AlignTrailingComments: true
13-
14-
AllowAllArgumentsOnNextLine: true
15-
AllowAllConstructorInitializersOnNextLine: true
16-
AllowAllParametersOfDeclarationOnNextLine: true
17-
18-
AllowShortBlocksOnASingleLine: Empty
19-
AllowShortCaseLabelsOnASingleLine: false
20-
AllowShortEnumsOnASingleLine: false
21-
AllowShortFunctionsOnASingleLine: Empty
22-
AllowShortIfStatementsOnASingleLine: Never
23-
AllowShortLambdasOnASingleLine: Inline
24-
AllowShortLoopsOnASingleLine: false
25-
26-
# AlwaysBreakAfterDefinitionReturnType is deprecated
27-
AlwaysBreakAfterReturnType: None
28-
AlwaysBreakBeforeMultilineStrings: false
29-
AlwaysBreakTemplateDeclarations: Yes
30-
31-
BinPackArguments: true
32-
BinPackParameters: true
33-
34-
BitFieldColonSpacing: Both
35-
1+
# find src/ tools/ tests/ examples/ benchmark/ -type f -name '*.c' -o -name '*.cpp' -o -name '*.h' | xargs -i clang-format -i {}
2+
3+
# need clang-format >= 10.0
4+
5+
AccessModifierOffset: -4
6+
AlignAfterOpenBracket: Align
7+
AlignConsecutiveAssignments: false
8+
# AlignConsecutiveBitFields: true
9+
AlignConsecutiveDeclarations: false
10+
AlignConsecutiveMacros: true
11+
AlignEscapedNewlines: Left
12+
# AlignOperands: AlignAfterOperator
13+
AlignTrailingComments: true
14+
AllowAllArgumentsOnNextLine: true
15+
AllowAllConstructorInitializersOnNextLine: true
16+
AllowAllParametersOfDeclarationOnNextLine: true
17+
AllowShortBlocksOnASingleLine: Always
18+
AllowShortCaseLabelsOnASingleLine: true
19+
# AllowShortEnumsOnASingleLine: true
20+
AllowShortFunctionsOnASingleLine: None
21+
AllowShortIfStatementsOnASingleLine: WithoutElse
22+
AllowShortLambdasOnASingleLine: All
23+
AllowShortLoopsOnASingleLine: true
24+
AlwaysBreakAfterReturnType: None
25+
AlwaysBreakBeforeMultilineStrings: false
26+
AlwaysBreakTemplateDeclarations: Yes
27+
BinPackArguments: true
28+
BinPackParameters: true
3629
BraceWrapping:
37-
AfterCaseLabel: true
38-
AfterClass: false
39-
AfterControlStatement: Always
40-
AfterEnum: true
41-
AfterFunction: true
42-
AfterNamespace: true
43-
AfterObjCDeclaration: true
44-
AfterStruct: true
45-
AfterUnion: true
46-
AfterExternBlock: true
47-
BeforeCatch: true
48-
BeforeElse: true
49-
BeforeLambdaBody: false
50-
BeforeWhile: true
51-
IndentBraces: false
52-
SplitEmptyFunction: false
53-
SplitEmptyRecord: false
54-
SplitEmptyNamespace: false
55-
BreakBeforeBinaryOperators: NonAssignment
56-
BreakBeforeBraces: Custom
57-
BreakBeforeConceptDeclarations: true
58-
BreakBeforeTernaryOperators: false
59-
BreakConstructorInitializers: BeforeColon
60-
BreakConstructorInitializersBeforeComma: false
61-
BreakInheritanceList: BeforeColon
62-
BreakStringLiterals: false
63-
64-
ColumnLimit: 120
65-
66-
CommentPragmas: '^ AYU pragma:'
67-
68-
CompactNamespaces: false
69-
70-
ConstructorInitializerAllOnOneLineOrOnePerLine: false
71-
ConstructorInitializerIndentWidth: 4
72-
73-
ContinuationIndentWidth: 4
74-
75-
Cpp11BracedListStyle: false
76-
77-
DeriveLineEnding: true
78-
DerivePointerAlignment: false
79-
80-
DisableFormat: false
81-
82-
ExperimentalAutoDetectBinPacking: false
83-
84-
FixNamespaceComments: true
85-
86-
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
87-
88-
IncludeCategories:
89-
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
90-
Priority: 2
91-
- Regex: '^(<|"(gtest|isl|json)/)'
92-
Priority: 3
93-
- Regex: '.*'
94-
Priority: 1
95-
96-
IndentCaseBlocks: true
97-
IndentCaseLabels: false
98-
IndentExternBlock: AfterExternBlock
99-
IndentGotoLabels: false
100-
IndentPPDirectives: BeforeHash
101-
IndentRequires: true
102-
IndentWidth: 4
103-
IndentWrappedFunctionNames: false
104-
105-
InsertTrailingCommas: Wrapped
106-
107-
KeepEmptyLinesAtTheStartOfBlocks: false
108-
109-
MacroBlockBegin: ''
110-
MacroBlockEnd: ''
111-
112-
MaxEmptyLinesToKeep: 3
113-
30+
AfterCaseLabel: true
31+
AfterClass: true
32+
AfterControlStatement: Always
33+
AfterEnum: true
34+
AfterFunction: true
35+
AfterNamespace: false
36+
AfterObjCDeclaration: false
37+
AfterStruct: true
38+
AfterUnion: true
39+
AfterExternBlock: false
40+
BeforeCatch: true
41+
BeforeElse: true
42+
# BeforeLambdaBody: false
43+
# BeforeWhile: false
44+
IndentBraces: false
45+
SplitEmptyFunction: true
46+
SplitEmptyRecord: true
47+
SplitEmptyNamespace: false
48+
BreakAfterJavaFieldAnnotations: true
49+
BreakBeforeBinaryOperators: All
50+
BreakBeforeBraces: Custom
51+
BreakBeforeTernaryOperators: true
52+
BreakConstructorInitializers: BeforeColon
53+
BreakInheritanceList: BeforeColon
54+
BreakStringLiterals: false
55+
ColumnLimit: 0
56+
# CommentPragmas:
57+
CompactNamespaces: false
58+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
59+
ConstructorInitializerIndentWidth: 4
60+
ContinuationIndentWidth: 4
61+
Cpp11BracedListStyle: true
62+
DeriveLineEnding: false
63+
DerivePointerAlignment: false
64+
# DisableFormat:
65+
# ExperimentalAutoDetectBinPacking:
66+
FixNamespaceComments: true
67+
# ForEachMacros:
68+
IncludeBlocks: Regroup
69+
# IncludeCategories:
70+
# IncludeIsMainRegex:
71+
# IncludeIsMainSourceRegex:
72+
# IndentCaseBlocks: false
73+
IndentCaseLabels: false
74+
# IndentExternBlock: NoIndent
75+
IndentGotoLabels: false
76+
IndentPPDirectives: None
77+
IndentWidth: 4
78+
# IndentWrappedFunctionNames: 4
79+
# InsertTrailingCommas: None
80+
# JavaImportGroups:
81+
# JavaScriptQuotes
82+
# JavaScriptWrapImports:
83+
KeepEmptyLinesAtTheStartOfBlocks: false
84+
Language: Cpp
85+
# MacroBlockBegin:
86+
# MacroBlockEnd:
87+
MaxEmptyLinesToKeep: 1
11488
NamespaceIndentation: None
115-
116-
ObjCBinPackProtocolList: Auto
117-
ObjCBlockIndentWidth: 4
118-
ObjCBreakBeforeNestedBlockParam: false
119-
ObjCSpaceAfterProperty: false
120-
ObjCSpaceBeforeProtocolList: true
121-
122-
PenaltyBreakBeforeFirstCallParameter: 19
123-
PenaltyBreakComment: 300
124-
PenaltyBreakFirstLessLess: 120
125-
PenaltyBreakString: 1000
126-
PenaltyExcessCharacter: 1000000
127-
PenaltyReturnTypeOnItsOwnLine: 60
128-
129-
PointerAlignment: Left
130-
131-
#RawStringFormats:
132-
133-
ReflowComments: false
134-
135-
SortIncludes: Never
136-
SortUsingDeclarations: false
137-
138-
SpaceAfterCStyleCast: false
139-
SpaceAfterLogicalNot: false
140-
SpaceAfterTemplateKeyword: true
141-
SpaceAroundPointerQualifiers: Before
142-
SpaceBeforeAssignmentOperators: true
143-
SpaceBeforeCaseColon: false
144-
SpaceBeforeCpp11BracedList: true
145-
SpaceBeforeCtorInitializerColon: true
146-
SpaceBeforeInheritanceColon: true
147-
SpaceBeforeParens: ControlStatements
148-
SpaceBeforeRangeBasedForLoopColon: true
149-
SpaceBeforeSquareBrackets: false
150-
SpaceInEmptyBlock: false
151-
SpaceInEmptyParentheses: false
152-
SpacesBeforeTrailingComments: 4
153-
SpacesInAngles: false
154-
SpacesInCStyleCastParentheses: false
155-
SpacesInConditionalStatement: false
156-
SpacesInContainerLiterals: true
157-
SpacesInParentheses: false
158-
SpacesInSquareBrackets: false
159-
160-
Standard: c++11
161-
162-
TabWidth: 4
163-
164-
UseCRLF: false
165-
166-
UseTab: Never
167-
168-
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
169-
# https://www.cnblogs.com/PaulpauL/p/5929753.html
170-
# https://my.oschina.net/u/4393102/blog/3349736
89+
# NamespaceMacros:
90+
# ObjCBinPackProtocolList:
91+
# ObjCBlockIndentWidth:
92+
# ObjCBreakBeforeNestedBlockParam:
93+
# ObjCSpaceAfterProperty:
94+
# ObjCSpaceBeforeProtocolList:
95+
# PenaltyBreakAssignment:
96+
# PenaltyBreakBeforeFirstCallParameter:
97+
# PenaltyBreakComment:
98+
# PenaltyBreakFirstLessLess:
99+
# PenaltyBreakString:
100+
# PenaltyBreakTemplateDeclaration:
101+
# PenaltyExcessCharacter:
102+
# PenaltyReturnTypeOnItsOwnLine:
103+
PointerAlignment: Left
104+
# RawStringFormats:
105+
ReflowComments: false
106+
SortIncludes: false
107+
SortUsingDeclarations: true
108+
SpaceAfterCStyleCast: false
109+
SpaceAfterLogicalNot: false
110+
SpaceAfterTemplateKeyword: false
111+
SpaceBeforeAssignmentOperators: true
112+
SpaceBeforeCpp11BracedList: false
113+
SpaceBeforeCtorInitializerColon: true
114+
SpaceBeforeInheritanceColon: true
115+
SpaceBeforeParens: ControlStatements
116+
SpaceBeforeRangeBasedForLoopColon: true
117+
SpaceBeforeSquareBrackets: false
118+
SpaceInEmptyBlock: false
119+
SpaceInEmptyParentheses: false
120+
SpacesBeforeTrailingComments: 1
121+
SpacesInAngles: false
122+
SpacesInCStyleCastParentheses: false
123+
SpacesInConditionalStatement: false
124+
SpacesInContainerLiterals: false
125+
SpacesInParentheses: false
126+
SpacesInSquareBrackets: false
127+
Standard: c++03
128+
#StatementMacros:
129+
TabWidth: 4
130+
# TypenameMacros:
131+
UseCRLF: false
132+
UseTab: Never

.github/workflows/code-format.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: code-format
2+
3+
on: [push, pull_request, pull_request_target]
4+
5+
jobs:
6+
code-format:
7+
runs-on: ubuntu-20.04
8+
steps:
9+
- uses: actions/checkout@v2
10+
11+
- name: apt
12+
run: |
13+
sudo apt-get update
14+
sudo apt-get install -y dos2unix clang-format-12
15+
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-12 120
16+
- name: code-format
17+
run: |
18+
python scripts/clang-format-all.py
19+
- uses: stefanzweifel/git-auto-commit-action@v4
20+
with:
21+
commit_message: apply code-format changes

0 commit comments

Comments
 (0)