Skip to content

Commit 371a894

Browse files
authored
Update clang-format and add clang-tidy (#9)
1 parent d00f310 commit 371a894

File tree

6 files changed

+335
-324
lines changed

6 files changed

+335
-324
lines changed

.clang-format

+59-73
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,26 @@
11
---
22
# Copyright © 2023 Alexandre Coderre-Chabot
33
#
4-
# This file is licensed under the MIT license. For more information, visit:
5-
# https://mit-license.org
4+
# https://github.com/acodcha/clang-format-tidy
65
#
7-
# Permission is hereby granted, free of charge, to any person obtaining a copy
8-
# of this software and associated documentation files (the "Software"), to deal
9-
# in the Software without restriction, including without limitation the rights
10-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11-
# copies of the Software, and to permit persons to whom the Software is
12-
# furnished to do so, subject to the following conditions:
13-
# - The above copyright notice and this permission notice shall be included in
14-
# all copies or substantial portions of the Software.
15-
# - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18-
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20-
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21-
# DEALINGS IN THE SOFTWARE.
6+
# This file is licensed under the MIT license (https://mit-license.org). Permission is hereby
7+
# granted, free of charge, to any person obtaining a copy of this software and associated
8+
# documentation files (the "Software"), to deal in the Software without restriction, including
9+
# without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10+
# sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
11+
# subject to the following conditions:
12+
# - The above copyright notice and this permission notice shall be included in all copies or
13+
# substantial portions of the Software.
14+
# - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
15+
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17+
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2219
#
23-
# This file was originally obtained from:
24-
# https://github.com/acodcha/clang-format
25-
#
26-
# This is a style configuration file for use with LLVM's ClangFormat automatic
27-
# source code formatter. For more information about ClangFormat, visit:
28-
# https://clang.llvm.org/docs/ClangFormat.html
29-
#
30-
# This file is compatible with ClangFormat version 14.0.0 or any later version.
31-
# To format your source code files, copy this file to the root directory of your
32-
# source code repository, name it either '.clang-format' or '_clang-format', and
33-
# run:
20+
# This is a configuration file for use with LLVM's ClangFormat automatic source code formatter
21+
# (https://clang.llvm.org/docs/ClangFormat.html). This file is compatible with ClangFormat version
22+
# 14.0.0 or any later version. To format your source code files, copy this file to the root
23+
# directory of your source code repository, name it ".clang-format", and run:
3424
# clang-format --style=file path/to/source/code/files
3525
#
3626
AccessModifierOffset: -2
@@ -57,7 +47,7 @@ AlwaysBreakAfterDefinitionReturnType: None
5747
AlwaysBreakAfterReturnType: None
5848
AlwaysBreakBeforeMultilineStrings: true
5949
AlwaysBreakTemplateDeclarations: Yes
60-
AttributeMacros: ['__capability']
50+
AttributeMacros: ["__capability"]
6151
BinPackArguments: true
6252
BinPackParameters: true
6353
BitFieldColonSpacing: Both
@@ -88,8 +78,8 @@ BreakBeforeTernaryOperators: false
8878
BreakConstructorInitializers: BeforeColon
8979
BreakInheritanceList: BeforeColon
9080
BreakStringLiterals: true
91-
ColumnLimit: 80
92-
CommentPragmas: '^ IWYU pragma:'
81+
ColumnLimit: 100
82+
CommentPragmas: "^ IWYU pragma:"
9383
CompactNamespaces: false
9484
ConstructorInitializerAllOnOneLineOrOnePerLine: false
9585
ConstructorInitializerIndentWidth: 2
@@ -102,24 +92,20 @@ EmptyLineAfterAccessModifier: Never
10292
EmptyLineBeforeAccessModifier: Always
10393
ExperimentalAutoDetectBinPacking: false
10494
FixNamespaceComments: true
105-
ForEachMacros: ['BOOST_FOREACH', 'FOREACH', 'foreach', 'Q_FOREACH']
106-
IfMacros: ['IF', 'KJ_IF_MAYBE']
95+
ForEachMacros: ["BOOST_FOREACH", "FOREACH", "foreach", "Q_FOREACH"]
96+
IfMacros: ["IF", "KJ_IF_MAYBE"]
10797
IncludeBlocks: Regroup
10898
IncludeCategories:
109-
- Regex: '^<.*\.h>' # C standard template library headers
110-
Priority: 1
111-
SortPriority: 1
112-
CaseSensitive: false
113-
- Regex: '^<.*' # C++ standard template library headers
114-
Priority: 2
115-
SortPriority: 2
116-
CaseSensitive: false
117-
- Regex: '.*' # All other headers
118-
Priority: 3
119-
SortPriority: 3
120-
CaseSensitive: false
121-
IncludeIsMainRegex: '([-_](test|unittest))?$'
122-
IncludeIsMainSourceRegex: ''
99+
- Regex: "^<.*"
100+
Priority: 1
101+
SortPriority: 1
102+
CaseSensitive: false
103+
- Regex: ".*"
104+
Priority: 2
105+
SortPriority: 2
106+
CaseSensitive: false
107+
IncludeIsMainRegex: "([-_](test|unittest))?$"
108+
IncludeIsMainSourceRegex: ""
123109
IndentAccessModifiers: false
124110
IndentCaseBlocks: true
125111
IndentCaseLabels: true
@@ -135,8 +121,8 @@ JavaScriptQuotes: Leave
135121
JavaScriptWrapImports: true
136122
KeepEmptyLinesAtTheStartOfBlocks: false
137123
LambdaBodyIndentation: Signature
138-
MacroBlockBegin: ''
139-
MacroBlockEnd: ''
124+
MacroBlockBegin: ""
125+
MacroBlockEnd: ""
140126
MaxEmptyLinesToKeep: 1
141127
NamespaceIndentation: None
142128
NamespaceMacros: []
@@ -149,33 +135,33 @@ PPIndentWidth: 2
149135
PackConstructorInitializers: BinPack
150136
PenaltyBreakAssignment: 4
151137
PenaltyBreakBeforeFirstCallParameter: 4
152-
PenaltyBreakComment: 16
138+
PenaltyBreakComment: 8
153139
PenaltyBreakFirstLessLess: 4
154140
PenaltyBreakOpenParenthesis: 4
155-
PenaltyBreakString: 32
141+
PenaltyBreakString: 100
156142
PenaltyBreakTemplateDeclaration: 0
157-
PenaltyExcessCharacter: 1024
143+
PenaltyExcessCharacter: 10000
158144
PenaltyIndentedWhitespace: 1
159-
PenaltyReturnTypeOnItsOwnLine: 32
145+
PenaltyReturnTypeOnItsOwnLine: 50
160146
PointerAlignment: Left
161147
QualifierAlignment: Left
162148
RawStringFormats:
163149
- Language: Cpp
164-
Delimiters: ['cc', 'CC', 'cpp', 'Cpp', 'CPP', 'c++', 'C++']
165-
CanonicalDelimiter: ''
150+
Delimiters: ["cc", "CC", "cpp", "Cpp", "CPP", "c++", "C++"]
151+
CanonicalDelimiter: ""
166152
BasedOnStyle: Google
167153
- Language: TextProto
168-
Delimiters: ['pb', 'PB', 'proto', 'PROTO']
154+
Delimiters: ["pb", "PB", "proto", "PROTO"]
169155
EnclosingFunctions:
170-
- 'EqualsProto'
171-
- 'EquivToProto'
172-
- 'PARSE_PARTIAL_TEXT_PROTO'
173-
- 'PARSE_TEST_PROTO'
174-
- 'PARSE_TEXT_PROTO'
175-
- 'ParseTextOrDie'
176-
- 'ParseTextProtoOrDie'
177-
- 'ParseTestProto'
178-
- 'ParsePartialTestProto'
156+
- "EqualsProto"
157+
- "EquivToProto"
158+
- "PARSE_PARTIAL_TEXT_PROTO"
159+
- "PARSE_TEST_PROTO"
160+
- "PARSE_TEXT_PROTO"
161+
- "ParseTextOrDie"
162+
- "ParseTextProtoOrDie"
163+
- "ParseTestProto"
164+
- "ParsePartialTestProto"
179165
CanonicalDelimiter: pb
180166
BasedOnStyle: Google
181167
ReferenceAlignment: Left
@@ -219,15 +205,15 @@ SpacesInLineCommentPrefix:
219205
SpacesInParentheses: false
220206
SpacesInSquareBrackets: false
221207
Standard: Latest
222-
StatementAttributeLikeMacros: ['Q_EMIT']
223-
StatementMacros: ['Q_UNUSED', 'QT_REQUIRE_VERSION']
208+
StatementAttributeLikeMacros: ["Q_EMIT"]
209+
StatementMacros: ["Q_UNUSED", "QT_REQUIRE_VERSION"]
224210
TabWidth: 8
225-
TypenameMacros: ['STACK_OF', 'LIST']
211+
TypenameMacros: ["STACK_OF", "LIST"]
226212
UseCRLF: false
227213
UseTab: Never
228214
WhitespaceSensitiveMacros:
229-
- 'STRINGIZE'
230-
- 'PP_STRINGIZE'
231-
- 'BOOST_PP_STRINGIZE'
232-
- 'NS_SWIFT_NAME'
233-
- 'CF_SWIFT_NAME'
215+
- "STRINGIZE"
216+
- "PP_STRINGIZE"
217+
- "BOOST_PP_STRINGIZE"
218+
- "NS_SWIFT_NAME"
219+
- "CF_SWIFT_NAME"

.clang-tidy

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
# Copyright © 2023 Alexandre Coderre-Chabot
3+
#
4+
# https://github.com/acodcha/clang-format-tidy
5+
#
6+
# This file is licensed under the MIT license (https://mit-license.org). Permission is hereby
7+
# granted, free of charge, to any person obtaining a copy of this software and associated
8+
# documentation files (the "Software"), to deal in the Software without restriction, including
9+
# without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10+
# sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
11+
# subject to the following conditions:
12+
# - The above copyright notice and this permission notice shall be included in all copies or
13+
# substantial portions of the Software.
14+
# - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
15+
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17+
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19+
#
20+
# This is a configuration file for use with LLVM's Clang-Tidy automatic source code linter
21+
# (https://clang.llvm.org/extra/clang-tidy). To run the linter on your source code files, copy this
22+
# file to the root directory of your source code repository, name it ".clang-tidy", and run:
23+
# clang-tidy --extra-arg=-std=c++20 /path/to/source/code/files
24+
#
25+
Checks: '
26+
*,
27+
abseil-*,
28+
altera-*,
29+
android-*,
30+
boost-*,
31+
bugprone-*,
32+
-bugprone-easily-swappable-parameters,
33+
cert-*,
34+
-cert-dcl21-cpp,
35+
-cert-err58-cpp,
36+
clang-analyzer-*,
37+
concurrency-*,
38+
cppcoreguidelines-*,
39+
-cppcoreguidelines-avoid-magic-numbers,
40+
-cppcoreguidelines-non-private-member-variables-in-classes,
41+
darwin-*,
42+
fuchsia-*,
43+
-fuchsia-default-arguments-calls,
44+
-fuchsia-default-arguments-declarations,
45+
-fuchsia-multiple-inheritance,
46+
-fuchsia-overloaded-operator,
47+
-fuchsia-trailing-return,
48+
-fuchsia-virtual-inheritance,
49+
google-*,
50+
-google-objc-avoid-throwing-exception,
51+
-google-objc-function-naming,
52+
-google-objc-global-variable-declaration,
53+
-google-readability-todo,
54+
hicpp-*,
55+
-hicpp-no-assembler,
56+
linuxkernel-*,
57+
llvm-*
58+
-llvm-header-guard,
59+
-llvm-include-order,
60+
llvmlibc-*,
61+
-llvmlibc-callee-namespace,
62+
-llvmlibc-implementation-in-namespace,
63+
-llvmlibc-inline-function-decl,
64+
-llvmlibc-restrict-system-libc-headers,
65+
misc-*,
66+
-misc-non-private-member-variables-in-classes,
67+
modernize-*,
68+
-modernize-use-trailing-return-type,
69+
mpi-*,
70+
objc-*,
71+
openmp-*,
72+
performance-*,
73+
-performance-avoid-endl,
74+
portability-*,
75+
-portability-restrict-system-includes,
76+
readability-*,
77+
-readability-function-cognitive-complexity,
78+
-readability-identifier-length,
79+
-readability-magic-numbers,
80+
zircon-*,
81+
-zircon-temporary-objects,
82+
'
83+
WarningsAsErrors: ''
84+
HeaderFilterRegex: ''
85+
AnalyzeTemporaryDtors: false
86+
FormatStyle: none
87+
User: ''
88+
CheckOptions:
89+
- key: hicpp-signed-bitwise.IgnorePositiveIntegerLiterals
90+
value: 'true'
91+
- key: readability-redundant-member-init.IgnoreBaseInCopyConstructors
92+
value: 'true'
93+
...

0 commit comments

Comments
 (0)