Skip to content

Commit bd61193

Browse files
authored
Fix clang-format CI: restrict to C/C++ extensions, modernize .clang-format (#527)
* Restrict clang-format CI to C/C++ file extensions * Modernize .clang-format to clang-format 21 schema
1 parent 48a86a4 commit bd61193

2 files changed

Lines changed: 180 additions & 35 deletions

File tree

.clang-format

Lines changed: 178 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,108 @@
11
---
22
Language: Cpp
3-
# BasedOnStyle: LLVM
43
AccessModifierOffset: -2
54
AlignAfterOpenBracket: Align
6-
AlignConsecutiveMacros: false
7-
AlignConsecutiveAssignments: false
8-
AlignConsecutiveBitFields: false
9-
AlignConsecutiveDeclarations: false
5+
AlignArrayOfStructures: None
6+
AlignConsecutiveAssignments:
7+
Enabled: false
8+
AcrossEmptyLines: false
9+
AcrossComments: false
10+
AlignCompound: false
11+
AlignFunctionDeclarations: false
12+
AlignFunctionPointers: false
13+
PadOperators: false
14+
AlignConsecutiveBitFields:
15+
Enabled: false
16+
AcrossEmptyLines: false
17+
AcrossComments: false
18+
AlignCompound: false
19+
AlignFunctionDeclarations: false
20+
AlignFunctionPointers: false
21+
PadOperators: false
22+
AlignConsecutiveDeclarations:
23+
Enabled: false
24+
AcrossEmptyLines: false
25+
AcrossComments: false
26+
AlignCompound: false
27+
AlignFunctionDeclarations: false
28+
AlignFunctionPointers: false
29+
PadOperators: false
30+
AlignConsecutiveMacros:
31+
Enabled: false
32+
AcrossEmptyLines: false
33+
AcrossComments: false
34+
AlignCompound: false
35+
AlignFunctionDeclarations: false
36+
AlignFunctionPointers: false
37+
PadOperators: false
38+
AlignConsecutiveShortCaseStatements:
39+
Enabled: false
40+
AcrossEmptyLines: false
41+
AcrossComments: false
42+
AlignCaseArrows: false
43+
AlignCaseColons: false
44+
AlignConsecutiveTableGenBreakingDAGArgColons:
45+
Enabled: false
46+
AcrossEmptyLines: false
47+
AcrossComments: false
48+
AlignCompound: false
49+
AlignFunctionDeclarations: false
50+
AlignFunctionPointers: false
51+
PadOperators: false
52+
AlignConsecutiveTableGenCondOperatorColons:
53+
Enabled: false
54+
AcrossEmptyLines: false
55+
AcrossComments: false
56+
AlignCompound: false
57+
AlignFunctionDeclarations: false
58+
AlignFunctionPointers: false
59+
PadOperators: false
60+
AlignConsecutiveTableGenDefinitionColons:
61+
Enabled: false
62+
AcrossEmptyLines: false
63+
AcrossComments: false
64+
AlignCompound: false
65+
AlignFunctionDeclarations: false
66+
AlignFunctionPointers: false
67+
PadOperators: false
1068
AlignEscapedNewlines: Right
1169
AlignOperands: Align
12-
AlignTrailingComments: true
70+
AlignTrailingComments:
71+
Kind: Always
72+
OverEmptyLines: 0
1373
AllowAllArgumentsOnNextLine: true
14-
AllowAllConstructorInitializersOnNextLine: true
1574
AllowAllParametersOfDeclarationOnNextLine: true
16-
AllowShortEnumsOnASingleLine: true
75+
AllowBreakBeforeNoexceptSpecifier: Never
1776
AllowShortBlocksOnASingleLine: Never
77+
AllowShortCaseExpressionOnASingleLine: true
1878
AllowShortCaseLabelsOnASingleLine: false
79+
AllowShortCompoundRequirementOnASingleLine: true
80+
AllowShortEnumsOnASingleLine: true
1981
AllowShortFunctionsOnASingleLine: All
20-
AllowShortLambdasOnASingleLine: All
2182
AllowShortIfStatementsOnASingleLine: Never
83+
AllowShortLambdasOnASingleLine: All
2284
AllowShortLoopsOnASingleLine: false
85+
AllowShortNamespacesOnASingleLine: false
2386
AlwaysBreakAfterDefinitionReturnType: None
24-
AlwaysBreakAfterReturnType: None
2587
AlwaysBreakBeforeMultilineStrings: false
26-
AlwaysBreakTemplateDeclarations: MultiLine
88+
AttributeMacros:
89+
- __capability
2790
BinPackArguments: true
28-
BinPackParameters: true
91+
BinPackLongBracedList: true
92+
BinPackParameters: BinPack
93+
BitFieldColonSpacing: Both
94+
BracedInitializerIndentWidth: -1
2995
BraceWrapping:
3096
AfterCaseLabel: false
3197
AfterClass: false
3298
AfterControlStatement: Never
3399
AfterEnum: false
100+
AfterExternBlock: false
34101
AfterFunction: false
35102
AfterNamespace: false
36103
AfterObjCDeclaration: false
37104
AfterStruct: false
38105
AfterUnion: false
39-
AfterExternBlock: false
40106
BeforeCatch: false
41107
BeforeElse: false
42108
BeforeLambdaBody: false
@@ -45,105 +111,184 @@ BraceWrapping:
45111
SplitEmptyFunction: true
46112
SplitEmptyRecord: true
47113
SplitEmptyNamespace: true
114+
BreakAdjacentStringLiterals: true
115+
BreakAfterAttributes: Leave
116+
BreakAfterJavaFieldAnnotations: false
117+
BreakAfterReturnType: None
118+
BreakArrays: true
48119
BreakBeforeBinaryOperators: None
120+
BreakBeforeConceptDeclarations: Always
49121
BreakBeforeBraces: Attach
50-
BreakBeforeInheritanceComma: false
51-
BreakInheritanceList: BeforeColon
122+
BreakBeforeInlineASMColon: OnlyMultiline
123+
BreakBeforeTemplateCloser: false
52124
BreakBeforeTernaryOperators: true
53-
BreakConstructorInitializersBeforeComma: false
125+
BreakBinaryOperations: Never
54126
BreakConstructorInitializers: BeforeColon
55-
BreakAfterJavaFieldAnnotations: false
127+
BreakFunctionDefinitionParameters: false
128+
BreakInheritanceList: BeforeColon
56129
BreakStringLiterals: true
130+
BreakTemplateDeclarations: MultiLine
57131
ColumnLimit: 80
58132
CommentPragmas: '^ IWYU pragma:'
59133
CompactNamespaces: false
60-
ConstructorInitializerAllOnOneLineOrOnePerLine: false
61134
ConstructorInitializerIndentWidth: 4
62135
ContinuationIndentWidth: 4
63136
Cpp11BracedListStyle: true
64-
DeriveLineEnding: true
65137
DerivePointerAlignment: false
66138
DisableFormat: false
139+
EmptyLineAfterAccessModifier: Never
140+
EmptyLineBeforeAccessModifier: LogicalBlock
141+
EnumTrailingComma: Leave
67142
ExperimentalAutoDetectBinPacking: false
68143
FixNamespaceComments: true
69144
ForEachMacros:
70145
- foreach
71146
- Q_FOREACH
72147
- BOOST_FOREACH
148+
IfMacros:
149+
- KJ_IF_MAYBE
73150
IncludeBlocks: Preserve
74151
IncludeCategories:
75152
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
76153
Priority: 2
77154
SortPriority: 0
155+
CaseSensitive: false
78156
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
79157
Priority: 3
80158
SortPriority: 0
159+
CaseSensitive: false
81160
- Regex: '.*'
82161
Priority: 1
83162
SortPriority: 0
163+
CaseSensitive: false
84164
IncludeIsMainRegex: '(Test)?$'
85165
IncludeIsMainSourceRegex: ''
86-
IndentCaseLabels: false
166+
IndentAccessModifiers: false
87167
IndentCaseBlocks: false
168+
IndentCaseLabels: false
169+
IndentExportBlock: true
170+
IndentExternBlock: AfterExternBlock
88171
IndentGotoLabels: true
89172
IndentPPDirectives: None
90-
IndentExternBlock: AfterExternBlock
173+
IndentRequiresClause: true
91174
IndentWidth: 2
92175
IndentWrappedFunctionNames: false
176+
InsertBraces: false
177+
InsertNewlineAtEOF: false
93178
InsertTrailingCommas: None
179+
IntegerLiteralSeparator:
180+
Binary: 0
181+
BinaryMinDigits: 0
182+
Decimal: 0
183+
DecimalMinDigits: 0
184+
Hex: 0
185+
HexMinDigits: 0
94186
JavaScriptQuotes: Leave
95187
JavaScriptWrapImports: true
96-
KeepEmptyLinesAtTheStartOfBlocks: true
188+
KeepEmptyLines:
189+
AtEndOfFile: false
190+
AtStartOfBlock: true
191+
AtStartOfFile: true
192+
KeepFormFeed: false
193+
LambdaBodyIndentation: Signature
194+
LineEnding: DeriveLF
97195
MacroBlockBegin: ''
98196
MacroBlockEnd: ''
197+
MainIncludeChar: Quote
99198
MaxEmptyLinesToKeep: 1
100199
NamespaceIndentation: None
101200
ObjCBinPackProtocolList: Auto
102201
ObjCBlockIndentWidth: 2
103202
ObjCBreakBeforeNestedBlockParam: true
104203
ObjCSpaceAfterProperty: false
105204
ObjCSpaceBeforeProtocolList: true
205+
OneLineFormatOffRegex: ''
206+
PackConstructorInitializers: BinPack
106207
PenaltyBreakAssignment: 2
107208
PenaltyBreakBeforeFirstCallParameter: 19
209+
PenaltyBreakBeforeMemberAccess: 150
108210
PenaltyBreakComment: 300
109211
PenaltyBreakFirstLessLess: 120
212+
PenaltyBreakOpenParenthesis: 0
213+
PenaltyBreakScopeResolution: 500
110214
PenaltyBreakString: 1000
111215
PenaltyBreakTemplateDeclaration: 10
112216
PenaltyExcessCharacter: 1000000
217+
PenaltyIndentedWhitespace: 0
113218
PenaltyReturnTypeOnItsOwnLine: 60
114219
PointerAlignment: Right
115-
ReflowComments: true
116-
SortIncludes: true
117-
SortUsingDeclarations: true
220+
PPIndentWidth: -1
221+
QualifierAlignment: Leave
222+
ReferenceAlignment: Pointer
223+
ReflowComments: Always
224+
RemoveBracesLLVM: false
225+
RemoveEmptyLinesInUnwrappedLines: false
226+
RemoveParentheses: Leave
227+
RemoveSemicolon: false
228+
RequiresClausePosition: OwnLine
229+
RequiresExpressionIndentation: OuterScope
230+
SeparateDefinitionBlocks: Leave
231+
ShortNamespaceLines: 1
232+
SkipMacroDefinitionBody: false
233+
SortIncludes:
234+
Enabled: true
235+
IgnoreCase: false
236+
SortJavaStaticImport: Before
237+
SortUsingDeclarations: LexicographicNumeric
118238
SpaceAfterCStyleCast: false
119239
SpaceAfterLogicalNot: false
240+
SpaceAfterOperatorKeyword: false
120241
SpaceAfterTemplateKeyword: true
242+
SpaceAroundPointerQualifiers: Default
121243
SpaceBeforeAssignmentOperators: true
244+
SpaceBeforeCaseColon: false
122245
SpaceBeforeCpp11BracedList: false
123246
SpaceBeforeCtorInitializerColon: true
124247
SpaceBeforeInheritanceColon: true
248+
SpaceBeforeJsonColon: false
125249
SpaceBeforeParens: ControlStatements
250+
SpaceBeforeParensOptions:
251+
AfterControlStatements: true
252+
AfterForeachMacros: true
253+
AfterFunctionDefinitionName: false
254+
AfterFunctionDeclarationName: false
255+
AfterIfMacros: true
256+
AfterNot: false
257+
AfterOverloadedOperator: false
258+
AfterPlacementOperator: true
259+
AfterRequiresInClause: false
260+
AfterRequiresInExpression: false
261+
BeforeNonEmptyParentheses: false
126262
SpaceBeforeRangeBasedForLoopColon: true
263+
SpaceBeforeSquareBrackets: false
127264
SpaceInEmptyBlock: false
128-
SpaceInEmptyParentheses: false
129265
SpacesBeforeTrailingComments: 1
130-
SpacesInAngles: false
131-
SpacesInConditionalStatement: false
266+
SpacesInAngles: Never
132267
SpacesInContainerLiterals: true
133-
SpacesInCStyleCastParentheses: false
134-
SpacesInParentheses: false
268+
SpacesInLineCommentPrefix:
269+
Minimum: 1
270+
Maximum: -1
271+
SpacesInParens: Never
272+
SpacesInParensOptions:
273+
ExceptDoubleParentheses: false
274+
InCStyleCasts: false
275+
InConditionalStatements: false
276+
InEmptyParentheses: false
277+
Other: false
135278
SpacesInSquareBrackets: false
136-
SpaceBeforeSquareBrackets: false
137279
Standard: Latest
280+
StatementAttributeLikeMacros:
281+
- Q_EMIT
138282
StatementMacros:
139283
- Q_UNUSED
140284
- QT_REQUIRE_VERSION
285+
TableGenBreakInsideDAGArg: DontBreak
141286
TabWidth: 8
142-
UseCRLF: false
143287
UseTab: Never
288+
VerilogBreakBetweenInstancePorts: true
144289
WhitespaceSensitiveMacros:
145290
- STRINGIZE
146291
- PP_STRINGIZE
147292
- BOOST_PP_STRINGIZE
293+
WrapNamespaceBodyWithEmptyLines: Leave
148294
...
149-

.github/workflows/format.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ jobs:
2929
run: |
3030
docker exec container /bin/bash -c 'cd ./Package; \
3131
source /cvmfs/sw.hsf.org/key4hep/setup.sh;\
32-
git clang-format --diff --style=file $(git merge-base upstream/master HEAD)
33-
git clang-format --diffstat --style=file $(git merge-base upstream/master HEAD)'
32+
git clang-format --diff --style=file --extensions c,h,cc,cpp,cxx,hh,hpp,hxx $(git merge-base upstream/master HEAD)
33+
git clang-format --diffstat --style=file --extensions c,h,cc,cpp,cxx,hh,hpp,hxx $(git merge-base upstream/master HEAD)'

0 commit comments

Comments
 (0)