Skip to content

Commit 2e29e89

Browse files
committed
adapted clang-tidy integration
1 parent e8e74dd commit 2e29e89

2 files changed

Lines changed: 106 additions & 19 deletions

File tree

.clang-tidy

Lines changed: 96 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,97 @@
11
---
2-
Checks: "*,
3-
-abseil-*,
4-
-altera-*,
5-
-android-*,
6-
-fuchsia-*,
7-
-google-*,
8-
-llvm*,
9-
-modernize-use-trailing-return-type,
10-
-zircon-*,
11-
-readability-else-after-return,
12-
-readability-static-accessed-through-instance,
13-
-readability-avoid-const-params-in-decls,
14-
-cppcoreguidelines-non-private-member-variables-in-classes,
15-
-misc-non-private-member-variables-in-classes,
16-
"
17-
HeaderFilterRegex: ''
18-
FormatStyle: none
2+
# Enable a curated set of check families relevant to a modern C++20 project.
3+
# Platform/framework-specific groups (abseil, altera, android, fuchsia,
4+
# google, llvm, zircon) are excluded entirely.
5+
Checks: >
6+
bugprone-*,
7+
cert-*,
8+
clang-analyzer-*,
9+
concurrency-*,
10+
cppcoreguidelines-*,
11+
misc-*,
12+
modernize-*,
13+
performance-*,
14+
portability-*,
15+
readability-*,
16+
-abseil-*,
17+
-altera-*,
18+
-android-*,
19+
-fuchsia-*,
20+
-google-*,
21+
-llvm-*,
22+
-llvmlibc-*,
23+
-zircon-*,
24+
-hicpp-*,
25+
-modernize-use-trailing-return-type,
26+
-readability-else-after-return,
27+
-readability-static-accessed-through-instance,
28+
-readability-avoid-const-params-in-decls,
29+
-cppcoreguidelines-non-private-member-variables-in-classes,
30+
-misc-non-private-member-variables-in-classes,
31+
-readability-magic-numbers,
32+
-cppcoreguidelines-avoid-magic-numbers,
33+
-cert-err58-cpp,
34+
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
35+
-cppcoreguidelines-pro-type-vararg,
36+
-misc-include-cleaner,
37+
38+
# Only analyse headers that belong to this project; ignore installed/conan deps.
39+
HeaderFilterRegex: '(src|test|fuzz_test)/.*'
40+
41+
# Treat every clang-tidy warning as an error (mirrors WARNINGS_AS_ERRORS).
42+
WarningsAsErrors: '*'
43+
44+
# Pick up the project .clang-format when applying fixes.
45+
FormatStyle: file
46+
47+
CheckOptions:
48+
# ---------- naming conventions (mirrors the project style) ----------
49+
- key: readability-identifier-naming.ClassCase
50+
value: CamelCase
51+
- key: readability-identifier-naming.StructCase
52+
value: CamelCase
53+
- key: readability-identifier-naming.EnumCase
54+
value: CamelCase
55+
- key: readability-identifier-naming.EnumConstantCase
56+
value: CamelCase
57+
- key: readability-identifier-naming.FunctionCase
58+
value: camelBack
59+
- key: readability-identifier-naming.MethodCase
60+
value: camelBack
61+
- key: readability-identifier-naming.MemberCase
62+
value: camelBack
63+
- key: readability-identifier-naming.PrivateMemberCase
64+
value: camelBack
65+
- key: readability-identifier-naming.PrivateMemberPrefix
66+
value: 'm_'
67+
- key: readability-identifier-naming.ParameterCase
68+
value: camelBack
69+
- key: readability-identifier-naming.LocalVariableCase
70+
value: camelBack
71+
- key: readability-identifier-naming.VariableCase
72+
value: camelBack
73+
- key: readability-identifier-naming.GlobalConstantCase
74+
value: UPPER_CASE
75+
- key: readability-identifier-naming.ConstexprVariableCase
76+
value: UPPER_CASE
77+
- key: readability-identifier-naming.NamespaceCase
78+
value: lower_case
79+
- key: readability-identifier-naming.TypeAliasCase
80+
value: CamelCase
81+
# ---------- thresholds ----------
82+
- key: readability-function-cognitive-complexity.Threshold
83+
value: '30'
84+
- key: readability-function-size.LineThreshold
85+
value: '80'
86+
- key: readability-function-size.StatementThreshold
87+
value: '50'
88+
- key: bugprone-easily-swappable-parameters.MinimumLength
89+
value: '3'
90+
- key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
91+
value: 'true'
92+
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctionsWhenCopyIsDeleted
93+
value: 'true'
94+
- key: modernize-use-default-member-init.UseAssignment
95+
value: 'false'
96+
- key: performance-unnecessary-value-param.AllowedTypes
97+
value: ''

cmake/StaticAnalyzers.cmake

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,18 @@ ENDIF()
1515
IF(ENABLE_CLANG_TIDY)
1616
FIND_PROGRAM(CLANG_TIDY_BINARY clang-tidy)
1717
IF(CLANG_TIDY_BINARY)
18-
SET(CMAKE_CXX_CLANG_TIDY
18+
SET(_clang_tidy_args
1919
${CLANG_TIDY_BINARY}
20+
--config-file=${CMAKE_SOURCE_DIR}/.clang-tidy
21+
--header-filter=${CMAKE_SOURCE_DIR}/(src|test|fuzz_test)/.*
2022
-extra-arg=-Wno-unknown-warning-option
21-
-p=${CMAKE_BINARY_DIR})
23+
-p=${CMAKE_BINARY_DIR}
24+
)
25+
IF(WARNINGS_AS_ERRORS)
26+
LIST(APPEND _clang_tidy_args --warnings-as-errors=*)
27+
ENDIF()
28+
SET(CMAKE_CXX_CLANG_TIDY ${_clang_tidy_args})
29+
MESSAGE(STATUS "clang-tidy enabled: ${CLANG_TIDY_BINARY}")
2230
ELSE()
2331
MESSAGE(SEND_ERROR "clang-tidy requested but executable not found")
2432
ENDIF()

0 commit comments

Comments
 (0)