Skip to content

Commit 9573250

Browse files
authored
build: Add clang-tidy checks and script (#1807)
1 parent 42f846b commit 9573250

File tree

2 files changed

+603
-0
lines changed

2 files changed

+603
-0
lines changed

.clang-tidy

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# TheSuperHackers @build JohnsterID 15/09/2025 Add clang-tidy configuration for code quality analysis
2+
---
3+
# Clang-tidy configuration for GeneralsGameCode project
4+
# This configuration is tailored for a legacy C++98/C++20 hybrid codebase
5+
# with Windows-specific code and COM interfaces
6+
7+
# Enable specific checks that are appropriate for this codebase
8+
Checks: >
9+
-*,
10+
bugprone-*,
11+
-bugprone-easily-swappable-parameters,
12+
-bugprone-implicit-widening-of-multiplication-result,
13+
-bugprone-narrowing-conversions,
14+
-bugprone-signed-char-misuse,
15+
cert-*,
16+
-cert-dcl21-cpp,
17+
-cert-dcl50-cpp,
18+
-cert-dcl58-cpp,
19+
-cert-env33-c,
20+
-cert-err58-cpp,
21+
clang-analyzer-*,
22+
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
23+
cppcoreguidelines-*,
24+
-cppcoreguidelines-avoid-c-arrays,
25+
-cppcoreguidelines-avoid-magic-numbers,
26+
-cppcoreguidelines-avoid-non-const-global-variables,
27+
-cppcoreguidelines-init-variables,
28+
-cppcoreguidelines-macro-usage,
29+
-cppcoreguidelines-no-malloc,
30+
-cppcoreguidelines-owning-memory,
31+
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
32+
-cppcoreguidelines-pro-bounds-constant-array-index,
33+
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
34+
-cppcoreguidelines-pro-type-cstyle-cast,
35+
-cppcoreguidelines-pro-type-reinterpret-cast,
36+
-cppcoreguidelines-pro-type-union-access,
37+
-cppcoreguidelines-pro-type-vararg,
38+
-cppcoreguidelines-special-member-functions,
39+
google-*,
40+
-google-build-using-namespace,
41+
-google-explicit-constructor,
42+
-google-readability-casting,
43+
-google-readability-todo,
44+
-google-runtime-int,
45+
-google-runtime-references,
46+
hicpp-*,
47+
-hicpp-avoid-c-arrays,
48+
-hicpp-explicit-conversions,
49+
-hicpp-no-array-decay,
50+
-hicpp-signed-bitwise,
51+
-hicpp-special-member-functions,
52+
-hicpp-uppercase-literal-suffix,
53+
-hicpp-use-auto,
54+
-hicpp-vararg,
55+
misc-*,
56+
-misc-const-correctness,
57+
-misc-include-cleaner,
58+
-misc-non-private-member-variables-in-classes,
59+
-misc-use-anonymous-namespace,
60+
modernize-*,
61+
-modernize-avoid-c-arrays,
62+
-modernize-concat-nested-namespaces,
63+
-modernize-loop-convert,
64+
-modernize-pass-by-value,
65+
-modernize-raw-string-literal,
66+
-modernize-return-braced-init-list,
67+
-modernize-use-auto,
68+
-modernize-use-default-member-init,
69+
-modernize-use-nodiscard,
70+
-modernize-use-trailing-return-type,
71+
performance-*,
72+
-performance-avoid-endl,
73+
portability-*,
74+
readability-*,
75+
-readability-avoid-const-params-in-decls,
76+
-readability-braces-around-statements,
77+
-readability-convert-member-functions-to-static,
78+
-readability-function-cognitive-complexity,
79+
-readability-identifier-length,
80+
-readability-implicit-bool-conversion,
81+
-readability-isolate-declaration,
82+
-readability-magic-numbers,
83+
-readability-named-parameter,
84+
-readability-redundant-access-specifiers,
85+
-readability-uppercase-literal-suffix
86+
87+
# Treat warnings as errors for CI/CD
88+
WarningsAsErrors: false
89+
90+
# Header filter to include project headers
91+
HeaderFilterRegex: '(Core|Generals|GeneralsMD|Dependencies)/.*\.(h|hpp)$'
92+
93+
# Check options for specific rules
94+
CheckOptions:
95+
# Naming conventions - adapted for the existing codebase style
96+
- key: readability-identifier-naming.ClassCase
97+
value: CamelCase
98+
- key: readability-identifier-naming.StructCase
99+
value: CamelCase
100+
- key: readability-identifier-naming.FunctionCase
101+
value: CamelCase
102+
- key: readability-identifier-naming.MethodCase
103+
value: CamelCase
104+
- key: readability-identifier-naming.VariableCase
105+
value: lower_case
106+
- key: readability-identifier-naming.ParameterCase
107+
value: lower_case
108+
- key: readability-identifier-naming.MemberCase
109+
value: lower_case
110+
- key: readability-identifier-naming.MemberPrefix
111+
value: m_
112+
- key: readability-identifier-naming.ConstantCase
113+
value: UPPER_CASE
114+
- key: readability-identifier-naming.EnumConstantCase
115+
value: UPPER_CASE
116+
- key: readability-identifier-naming.MacroDefinitionCase
117+
value: UPPER_CASE
118+
119+
# Performance settings
120+
- key: performance-for-range-copy.WarnOnAllAutoCopies
121+
value: true
122+
- key: performance-unnecessary-value-param.AllowedTypes
123+
value: 'AsciiString;UnicodeString;Utf8String;Utf16String'
124+
125+
# Modernize settings - be conservative for legacy code
126+
- key: modernize-use-nullptr.NullMacros
127+
value: 'NULL'
128+
- key: modernize-replace-auto-ptr.IncludeStyle
129+
value: llvm
130+
131+
# Readability settings
132+
- key: readability-function-size.LineThreshold
133+
value: 150
134+
- key: readability-function-size.StatementThreshold
135+
value: 100
136+
- key: readability-function-size.BranchThreshold
137+
value: 25
138+
- key: readability-function-size.ParameterThreshold
139+
value: 8
140+
- key: readability-function-size.NestingThreshold
141+
value: 6
142+
143+
# Bugprone settings
144+
- key: bugprone-argument-comment.StrictMode
145+
value: false
146+
- key: bugprone-suspicious-string-compare.WarnOnImplicitComparison
147+
value: true
148+
- key: bugprone-suspicious-string-compare.WarnOnLogicalNotComparison
149+
value: true
150+
151+
# Google style settings
152+
- key: google-readability-braces-around-statements.ShortStatementLines
153+
value: 2
154+
- key: google-readability-function-size.StatementThreshold
155+
value: 100
156+
157+
# CERT settings
158+
- key: cert-dcl16-c.NewSuffixes
159+
value: 'L;LL;LU;LLU'
160+
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
161+
value: false
162+
163+
# Use .clang-format for formatting suggestions
164+
FormatStyle: file
165+
166+
# Exclude certain directories and files
167+
# Note: This is handled by HeaderFilterRegex above, but can be extended

0 commit comments

Comments
 (0)