Skip to content

Commit 4166e6b

Browse files
committed
add a check-formatting rule
1 parent c2fdd37 commit 4166e6b

File tree

2 files changed

+194
-0
lines changed

2 files changed

+194
-0
lines changed

.clang-format

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
---
2+
Language: Cpp
3+
# BasedOnStyle: WebKit
4+
AccessModifierOffset: -4
5+
AlignAfterOpenBracket: Align
6+
#AlignAfterOpenBracket: DontAlign
7+
AlignArrayOfStructures: None
8+
AlignConsecutiveMacros: None
9+
AlignConsecutiveAssignments: None
10+
AlignConsecutiveBitFields: None
11+
AlignConsecutiveDeclarations: None
12+
AlignEscapedNewlines: Right
13+
AlignOperands: DontAlign
14+
AlignTrailingComments: false
15+
AllowAllArgumentsOnNextLine: true
16+
AllowAllConstructorInitializersOnNextLine: true
17+
AllowAllParametersOfDeclarationOnNextLine: true
18+
AllowShortEnumsOnASingleLine: true
19+
AllowShortBlocksOnASingleLine: Empty
20+
AllowShortCaseLabelsOnASingleLine: false
21+
AllowShortFunctionsOnASingleLine: All
22+
AllowShortLambdasOnASingleLine: All
23+
AllowShortIfStatementsOnASingleLine: Never
24+
AllowShortLoopsOnASingleLine: false
25+
AlwaysBreakAfterDefinitionReturnType: None
26+
AlwaysBreakAfterReturnType: TopLevelDefinitions
27+
#AlwaysBreakAfterReturnType: None
28+
AlwaysBreakBeforeMultilineStrings: false
29+
AlwaysBreakTemplateDeclarations: MultiLine
30+
AttributeMacros:
31+
- __capability
32+
BinPackArguments: true
33+
BinPackParameters: true
34+
BraceWrapping:
35+
AfterCaseLabel: false
36+
AfterClass: false
37+
AfterControlStatement: Never
38+
AfterEnum: false
39+
AfterFunction: true
40+
AfterNamespace: false
41+
AfterObjCDeclaration: false
42+
AfterStruct: false
43+
AfterUnion: false
44+
AfterExternBlock: false
45+
BeforeCatch: false
46+
BeforeElse: false
47+
BeforeLambdaBody: false
48+
BeforeWhile: false
49+
IndentBraces: false
50+
SplitEmptyFunction: true
51+
SplitEmptyRecord: true
52+
SplitEmptyNamespace: true
53+
BreakBeforeBinaryOperators: All
54+
BreakBeforeConceptDeclarations: true
55+
BreakBeforeBraces: WebKit
56+
BreakBeforeInheritanceComma: false
57+
BreakInheritanceList: BeforeColon
58+
BreakBeforeTernaryOperators: true
59+
BreakConstructorInitializersBeforeComma: false
60+
BreakConstructorInitializers: BeforeComma
61+
BreakAfterJavaFieldAnnotations: false
62+
BreakStringLiterals: true
63+
ColumnLimit: 0
64+
CommentPragmas: '^ IWYU pragma:'
65+
CompactNamespaces: false
66+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
67+
ConstructorInitializerIndentWidth: 4
68+
ContinuationIndentWidth: 8
69+
#ContinuationIndentWidth: 4
70+
Cpp11BracedListStyle: false
71+
DeriveLineEnding: true
72+
DerivePointerAlignment: false
73+
DisableFormat: false
74+
EmptyLineAfterAccessModifier: Never
75+
EmptyLineBeforeAccessModifier: LogicalBlock
76+
ExperimentalAutoDetectBinPacking: true
77+
#ExperimentalAutoDetectBinPacking: false
78+
FixNamespaceComments: false
79+
ForEachMacros:
80+
- foreach
81+
- Q_FOREACH
82+
- BOOST_FOREACH
83+
IfMacros:
84+
- KJ_IF_MAYBE
85+
IncludeBlocks: Preserve
86+
IncludeCategories:
87+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
88+
Priority: 2
89+
SortPriority: 0
90+
CaseSensitive: false
91+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
92+
Priority: 3
93+
SortPriority: 0
94+
CaseSensitive: false
95+
- Regex: '.*'
96+
Priority: 1
97+
SortPriority: 0
98+
CaseSensitive: false
99+
IncludeIsMainRegex: '(Test)?$'
100+
IncludeIsMainSourceRegex: ''
101+
IndentAccessModifiers: false
102+
IndentCaseLabels: false
103+
IndentCaseBlocks: false
104+
IndentGotoLabels: true
105+
IndentPPDirectives: None
106+
IndentExternBlock: AfterExternBlock
107+
IndentRequires: false
108+
IndentWidth: 4
109+
IndentWrappedFunctionNames: false
110+
InsertTrailingCommas: None
111+
JavaScriptQuotes: Leave
112+
JavaScriptWrapImports: true
113+
KeepEmptyLinesAtTheStartOfBlocks: true
114+
LambdaBodyIndentation: Signature
115+
MacroBlockBegin: ''
116+
MacroBlockEnd: ''
117+
MaxEmptyLinesToKeep: 1
118+
NamespaceIndentation: Inner
119+
ObjCBinPackProtocolList: Auto
120+
ObjCBlockIndentWidth: 4
121+
ObjCBreakBeforeNestedBlockParam: true
122+
ObjCSpaceAfterProperty: true
123+
ObjCSpaceBeforeProtocolList: true
124+
PenaltyBreakAssignment: 2
125+
PenaltyBreakBeforeFirstCallParameter: 19
126+
PenaltyBreakComment: 300
127+
PenaltyBreakFirstLessLess: 120
128+
PenaltyBreakString: 1000
129+
PenaltyBreakTemplateDeclaration: 10
130+
PenaltyExcessCharacter: 1000000
131+
PenaltyReturnTypeOnItsOwnLine: 60
132+
PenaltyIndentedWhitespace: 0
133+
PointerAlignment: Left
134+
PPIndentWidth: -1
135+
ReferenceAlignment: Pointer
136+
ReflowComments: false
137+
#ReflowComments: true
138+
ShortNamespaceLines: 1
139+
SortIncludes: false
140+
#SortIncludes: CaseSensitive
141+
SortJavaStaticImport: Before
142+
SortUsingDeclarations: true
143+
SpaceAfterCStyleCast: false
144+
SpaceAfterLogicalNot: false
145+
SpaceAfterTemplateKeyword: true
146+
SpaceBeforeAssignmentOperators: true
147+
SpaceBeforeCaseColon: false
148+
SpaceBeforeCpp11BracedList: true
149+
SpaceBeforeCtorInitializerColon: true
150+
SpaceBeforeInheritanceColon: true
151+
SpaceBeforeParens: ControlStatements
152+
SpaceAroundPointerQualifiers: Default
153+
SpaceBeforeRangeBasedForLoopColon: true
154+
SpaceInEmptyBlock: true
155+
SpaceInEmptyParentheses: false
156+
SpacesBeforeTrailingComments: 1
157+
SpacesInAngles: Never
158+
SpacesInConditionalStatement: false
159+
SpacesInContainerLiterals: true
160+
SpacesInCStyleCastParentheses: false
161+
SpacesInLineCommentPrefix:
162+
Minimum: 1
163+
Maximum: -1
164+
SpacesInParentheses: false
165+
SpacesInSquareBrackets: false
166+
SpaceBeforeSquareBrackets: false
167+
BitFieldColonSpacing: Both
168+
Standard: Latest
169+
StatementAttributeLikeMacros:
170+
- Q_EMIT
171+
StatementMacros:
172+
- Q_UNUSED
173+
- QT_REQUIRE_VERSION
174+
TabWidth: 8
175+
UseCRLF: false
176+
UseTab: Never
177+
WhitespaceSensitiveMacros:
178+
- STRINGIZE
179+
- PP_STRINGIZE
180+
- BOOST_PP_STRINGIZE
181+
- NS_SWIFT_NAME
182+
- CF_SWIFT_NAME
183+
...
184+

.github/workflows/ccpp.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ on:
77
branches: [ "*" ]
88

99
jobs:
10+
check-formatting:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v1
14+
- name: check-format
15+
run: |
16+
echo "Checking format of sourcecode..."
17+
find . -type f \( -name '*.c' -o -name '*.h' \) -print0 | xargs -r0 clang-format -i
18+
git diff --color # --exit-code
19+
1020
build:
1121

1222
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)