Skip to content

Commit d9ad9fa

Browse files
committed
🔨 Update clang format and add a clang tidy
1 parent c89b4c6 commit d9ad9fa

File tree

3 files changed

+232
-6
lines changed

3 files changed

+232
-6
lines changed

Plugin/.clang-format

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

Plugin/.clang-tidy

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
# Configure clang-tidy for this project.
3+
4+
# Here is an explanation for why some of the checks are disabled:
5+
#
6+
# -google-readability-namespace-comments: the *_CLIENT_NS is a macro, and
7+
# clang-tidy fails to match it against the initial value.
8+
#
9+
# -modernize-use-trailing-return-type: clang-tidy recommends using
10+
# `auto Foo() -> std::string { return ...; }`, we think the code is less
11+
# readable in this form.
12+
#
13+
# -modernize-return-braced-init-list: We think removing typenames and using
14+
# only braced-init can hurt readability.
15+
#
16+
# -modernize-avoid-c-arrays: We only use C arrays when they seem to be the
17+
# right tool for the job, such as `char foo[] = "hello"`. In these cases,
18+
# avoiding C arrays often makes the code less readable, and std::array is
19+
# not a drop-in replacement because it doesn't deduce the size.
20+
#
21+
# -performance-move-const-arg: This warning requires the developer to
22+
# know/care more about the implementation details of types/functions than
23+
# should be necessary. For example, `A a; F(std::move(a));` will trigger a
24+
# warning IFF `A` is a trivial type (and therefore the move is
25+
# meaningless). It would also warn if `F` accepts by `const&`, which is
26+
# another detail that the caller need not care about.
27+
#
28+
# -readability-redundant-declaration: A friend declaration inside a class
29+
# counts as a declaration, so if we also declare that friend outside the
30+
# class in order to document it as part of the public API, that will
31+
# trigger a redundant declaration warning from this check.
32+
#
33+
# -readability-function-cognitive-complexity: too many false positives with
34+
# clang-tidy-12. We need to disable this check in macros, and that setting
35+
# only appears in clang-tidy-13.
36+
#
37+
# -bugprone-narrowing-conversions: too many false positives around
38+
# `std::size_t` vs. `*::difference_type`.
39+
#
40+
Checks: >
41+
-*,
42+
bugprone-*,
43+
google-*,
44+
misc-*,
45+
modernize-*,
46+
performance-*,
47+
portability-*,
48+
readability-*,
49+
-google-readability-braces-around-statements,
50+
-google-readability-namespace-comments,
51+
-google-runtime-references,
52+
-misc-non-private-member-variables-in-classes,
53+
-modernize-return-braced-init-list,
54+
-modernize-use-trailing-return-type,
55+
-modernize-avoid-c-arrays,
56+
-performance-move-const-arg,
57+
-readability-braces-around-statements,
58+
-readability-magic-numbers,
59+
-readability-named-parameter,
60+
-readability-redundant-declaration,
61+
-readability-function-cognitive-complexity,
62+
-bugprone-narrowing-conversions
63+
# Turn all the warnings from the checks above into errors.
64+
# WarningsAsErrors: "*"
65+
66+
67+
CheckOptions:
68+
- { key: readability-identifier-naming.NamespaceCase, value: CamelCase }
69+
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
70+
- { key: readability-identifier-naming.StructCase, value: CamelCase }
71+
- { key: readability-identifier-naming.TemplateParameterCase, value: CamelCase }
72+
- { key: readability-identifier-naming.FunctionCase, value: camelCase }
73+
- { key: readability-identifier-naming.VariableCase, value: camelBack }
74+
- { key: readability-identifier-naming.ClassMemberCase, value: camelBack }
75+
- { key: readability-identifier-naming.ProtectedMemberPrefix, value: _ }
76+
- { key: readability-identifier-naming.PrivateMemberPrefix, value: _ }
77+
- { key: readability-identifier-naming.EnumConstantCase, value: CamelCase }
78+
- { key: readability-identifier-naming.ConstexprVariableCase, value: CamelCase }
79+
- { key: readability-identifier-naming.GlobalConstantCase, value: CamelCase }
80+
- { key: readability-identifier-naming.MemberConstantCase, value: CamelCase }
81+
- { key: readability-identifier-naming.StaticConstantCase, value: CamelCase }
82+
- { key: readability-identifier-naming.StaticVariableCase, value: camelBack }
83+
- { key: readability-implicit-bool-conversion.AllowIntegerConditions, value: 1 }
84+
- { key: readability-implicit-bool-conversion.AllowPointerConditions, value: 1 }

Plugin/index.clang-format

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)