Skip to content

Commit 4b659e5

Browse files
committed
chore: add clang-format and clang-tidy configuration files for code style and quality checks
1 parent 9c4d6c6 commit 4b659e5

3 files changed

Lines changed: 407 additions & 1 deletion

File tree

.clang-format

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
Language: Cpp
3+
BasedOnStyle: Google
4+
AccessModifierOffset: -2
5+
AlignAfterOpenBracket: Align
6+
AlignConsecutiveAssignments: false
7+
AlignConsecutiveDeclarations: false
8+
AlignOperands: true
9+
AlignTrailingComments: true
10+
AllowShortBlocksOnASingleLine: Never
11+
AllowShortCaseLabelsOnASingleLine: false
12+
AllowShortFunctionsOnASingleLine: None
13+
AllowShortIfStatementsOnASingleLine: false
14+
AllowShortLoopsOnASingleLine: false
15+
AlwaysBreakAfterDefinitionReturnType: None
16+
AlwaysBreakAfterReturnType: None
17+
AlwaysBreakTemplateDeclarations: Yes
18+
BinPackArguments: false
19+
BinPackParameters: false
20+
BraceWrapping:
21+
AfterCaseLabel: false
22+
AfterClass: false
23+
AfterControlStatement: false
24+
AfterEnum: false
25+
AfterFunction: false
26+
AfterNamespace: false
27+
AfterStruct: false
28+
AfterUnion: false
29+
AfterExternBlock: false
30+
BeforeCatch: false
31+
BeforeElse: false
32+
BeforeLambdaBody: false
33+
BeforeWhile: false
34+
SplitEmptyFunction: false
35+
SplitEmptyRecord: false
36+
SplitEmptyNamespace: false
37+
AfterObjCDeclaration: false
38+
IndentBraces: false
39+
BreakBeforeBraces: Custom
40+
BreakBeforeTernaryOperators: true
41+
BreakConstructorInitializers: AfterColon
42+
BreakConstructorInitializersBeforeComma: false
43+
ColumnLimit: 120
44+
CompactNamespaces: false
45+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
46+
ContinuationIndentWidth: 4
47+
EmptyLineAfterAccessModifier: Never
48+
EmptyLineBeforeAccessModifier: LogicalBlock
49+
IncludeBlocks: Preserve
50+
IncludeCategories:
51+
- Regex: '^<.*'
52+
Priority: 1
53+
- Regex: '^".*'
54+
Priority: 2
55+
- Regex: '.*'
56+
Priority: 3
57+
IncludeIsMainRegex: ([-_](test|unittest))?$'([-_](test|unittest))?$'
58+
IndentCaseBlocks: false
59+
IndentCaseLabels: true
60+
IndentGotoLabels: true
61+
IndentPPDirectives: None
62+
IndentWidth: 2
63+
IndentWrappedFunctionNames: false
64+
InsertNewlineAtEOF: true
65+
MacroBlockBegin: ''
66+
MacroBlockEnd: ''
67+
MaxEmptyLinesToKeep: 1
68+
NamespaceIndentation: None
69+
PointerAlignment: Left
70+
SpaceAfterCStyleCast: true
71+
SpaceAfterLogicalNot: false
72+
SpaceAfterTemplateKeyword: false
73+
SpaceBeforeAssignmentOperators: true
74+
SpaceBeforeInheritanceColon: true
75+
SpaceBeforeParens: ControlStatements
76+
SpaceBeforeRangeBasedForLoopColon: true
77+
SpaceBeforeSquareBrackets: false
78+
SpaceInEmptyParentheses: false
79+
SpacesBeforeTrailingComments: 1
80+
SpacesInAngles: false
81+
SpacesInConditionalStatement: false
82+
SpacesInCStyleCastParentheses: false
83+
SpacesInParentheses: false
84+
SpacesInSquareBrackets: false
85+
TabWidth: 4
86+
UseTab: Never
87+
...

.clang-tidy

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
Checks: "-*,
2+
modernize-*,
3+
performance-*,
4+
cppcoreguidelines-*,
5+
bugprone-*,
6+
misc-header-include-cycle,
7+
readability-delete-null-pointer,
8+
readability-identifier-naming,
9+
readability-misleading-indentation,
10+
readability-redundant-control-flow,
11+
readability-static-accessed-through-instance,
12+
llvm-namespace-comment,
13+
-modernize-use-trailing-return-type,
14+
-performance-no-int-to-ptr,
15+
-cppcoreguidelines-avoid-const-or-ref-data-members,
16+
-cppcoreguidelines-pro-type-reinterpret-cast,
17+
-cppcoreguidelines-pro-type-union-access,
18+
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
19+
-bugprone-exception-escape,
20+
-bugprone-easily-swappable-parameters"
21+
22+
WarningsAsErrors: ""
23+
HeaderFilterRegex: ""
24+
FormatStyle: none
25+
26+
# clang-tidy uses Clang for parsing (not g++), so on Windows it defaults to MSVC
27+
# target/system headers. Our project builds with MinGW-w64; force GNU target and
28+
# point Clang at the MinGW toolchain so flags like -mthreads work correctly.
29+
# Uncomment on Windows
30+
#ExtraArgsBefore:
31+
# - "--target=x86_64-w64-windows-gnu"
32+
# - "--gcc-toolchain=C:/Program Files/mingw64"
33+
CheckOptions:
34+
- key: modernize-use-using.IgnoreMacros
35+
value: "true"
36+
- key: readability-identifier-naming.NamespaceCase
37+
value: "lower_case"
38+
- key: readability-identifier-naming.ClassCase
39+
value: "CamelCase"
40+
- key: readability-identifier-naming.StructCase
41+
value: "CamelCase"
42+
- key: readability-identifier-naming.TemplateParameterCase
43+
value: "CamelCase"
44+
- key: readability-identifier-naming.FunctionCase
45+
value: "CamelCase"
46+
- key: readability-identifier-naming.VariableCase
47+
value: "lower_case"
48+
- key: readability-identifier-naming.ClassMemberCase
49+
value: "lower_case"
50+
- key: readability-identifier-naming.ClassMemberSuffix
51+
value: "_"
52+
- key: readability-identifier-naming.PrivateMemberSuffix
53+
value: "_"
54+
- key: readability-identifier-naming.ProtectedMemberSuffix
55+
value: "_"
56+
- key: readability-identifier-naming.EnumConstantCase
57+
value: "CamelCase"
58+
- key: readability-identifier-naming.EnumConstantPrefix
59+
value: "k"
60+
- key: readability-identifier-naming.ConstexprVariableCase
61+
value: "CamelCase"
62+
- key: readability-identifier-naming.ConstexprVariablePrefix
63+
value: "k"
64+
- key: readability-identifier-naming.GlobalConstantCase
65+
value: "CamelCase"
66+
- key: readability-identifier-naming.GlobalConstantPrefix
67+
value: "k"
68+
- key: readability-identifier-naming.MemberConstantCase
69+
value: "CamelCase"
70+
- key: readability-identifier-naming.MemberConstantPrefix
71+
value: "k"
72+
- key: readability-identifier-naming.StaticConstantCase
73+
value: "CamelCase"
74+
- key: readability-identifier-naming.StaticConstantPrefix
75+
value: "k"
76+
- key: readability-identifier-naming.StructCase
77+
value: "CamelCase"
78+
- key: readability-identifier-naming.TemplateParameterCase
79+
value: "CamelCase"
80+
- key: readability-identifier-naming.FunctionCase
81+
value: "CamelCase"
82+
- key: readability-identifier-naming.VariableCase
83+
value: "lower_case"
84+
- key: readability-identifier-naming.ClassMemberCase
85+
value: "lower_case"
86+
- key: readability-identifier-naming.ClassMemberSuffix
87+
value: "_"
88+
- key: readability-identifier-naming.PrivateMemberSuffix
89+
value: "_"
90+
- key: readability-identifier-naming.ProtectedMemberSuffix
91+
value: "_"
92+
- key: readability-identifier-naming.EnumConstantCase
93+
value: "CamelCase"
94+
- key: readability-identifier-naming.EnumConstantPrefix
95+
value: "k"
96+
- key: readability-identifier-naming.ConstexprVariableCase
97+
value: "CamelCase"
98+
- key: readability-identifier-naming.ConstexprVariablePrefix
99+
value: "k"
100+
- key: readability-identifier-naming.GlobalConstantCase
101+
value: "CamelCase"
102+
- key: readability-identifier-naming.GlobalConstantPrefix
103+
value: "k"
104+
- key: readability-identifier-naming.MemberConstantCase
105+
value: "CamelCase"
106+
- key: readability-identifier-naming.MemberConstantPrefix
107+
value: "k"
108+
- key: readability-identifier-naming.StaticConstantCase
109+
value: "CamelCase"
110+
- key: readability-identifier-naming.StaticConstantPrefix
111+
value: "k"

0 commit comments

Comments
 (0)