| 1 |
--- |
| 2 |
# clang-tidy configuration |
| 3 |
# |
| 4 |
# clang-tidy can be run manually like this from CMake v3.26: |
| 5 |
# |
| 6 |
# cmake -S. -Bbuild -DCMAKE_CXX_CLANG_TIDY=clang-tidy -DCMAKE_CXX_CLANG_TIDY_EXPORT_FIXES_DIR=clang-tidy-fixes |
| 7 |
# cmake --build build |
| 8 |
# |
| 9 |
# To export fixes suggested by clang-tidy, run: |
| 10 |
# |
| 11 |
# clang-apply-replacements build/clang-tidy-fixes |
| 12 |
# |
| 13 |
# To limit the run to certain checks, run: |
| 14 |
# |
| 15 |
# cmake -S. -Bbuild -DCMAKE_CXX_CLANG_TIDY="clang-tidy;-checks='-*,modernize-use-nodiscard'" |
| 16 |
# |
| 17 |
# clang-tidy also has several IDE integrations listed here: |
| 18 |
# https://clang.llvm.org/extra/clang-tidy/Integrations.html |
| 19 |
|
| 20 |
HeaderFilterRegex: ".*" |
| 21 |
|
| 22 |
# Enable most checks. |
| 23 |
# |
| 24 |
# Built-in checks: |
| 25 |
# https://clang.llvm.org/extra/clang-tidy/checks/list.html |
| 26 |
# |
| 27 |
# Exclusions: |
| 28 |
# |
| 29 |
# -modernize-avoid-c-arrays |
| 30 |
# `std::array` is not always good replacement |
| 31 |
# because its length is not deduced. |
| 32 |
# |
| 33 |
# -modernize-use-constraints |
| 34 |
# C++17 does not have constraints. |
| 35 |
# |
| 36 |
# -modernize-use-trailing-return-type |
| 37 |
# -readability-function-cognitive-complexity |
| 38 |
# Subjective and/or stylistic checks. |
| 39 |
Checks: > |
| 40 |
-*, |
| 41 |
bugprone-*, |
| 42 |
cppcoreguidelines-pro-type-cstyle-cast, |
| 43 |
google-runtime-int, |
| 44 |
llvm-include-order, |
| 45 |
llvm-namespace-comment, |
| 46 |
misc-*, |
| 47 |
modernize-*, |
| 48 |
performance-*, |
| 49 |
portability-*, |
| 50 |
readability-*, |
| 51 |
-readability-function-cognitive-complexity, |
| 52 |
-readability-identifier-length, |
| 53 |
-bugprone-easily-swappable-parameters, |
| 54 |
-readability-magic-numbers, |
| 55 |
-misc-non-private-member-variables-in-classes, |
| 56 |
-modernize-avoid-c-arrays, |
| 57 |
-modernize-use-trailing-return-type, |
| 58 |
-modernize-use-constraints |
| 59 |
|
| 60 |
CheckOptions: |
| 61 |
- { key: readability-identifier-naming.NamespaceCase, value: lower_case } |
| 62 |
- { key: readability-identifier-naming.ClassCase, value: CamelCase } |
| 63 |
- { key: readability-identifier-naming.StructCase, value: CamelCase } |
| 64 |
- { key: readability-identifier-naming.TemplateParameterCase, value: CamelCase } |
| 65 |
- { key: readability-identifier-naming.MethodCase, value: lower_case } |
| 66 |
- { key: readability-identifier-naming.FunctionCase, value: aNy_CasE } |
| 67 |
- { key: readability-identifier-naming.ParameterCase, value: lower_case } |
| 68 |
- { key: readability-identifier-naming.MemberCase, value: lower_case } |
| 69 |
- { key: readability-identifier-naming.VariableCase, value: lower_case } |
| 70 |
- { key: readability-identifier-naming.ClassMemberCase, value: lower_case } |
| 71 |
- { key: readability-identifier-naming.GlobalVariableCase, value: aNy_CasE } |
| 72 |
- { key: readability-identifier-naming.GlobalFunctionCase, value: aNy_CasE } |
| 73 |
- { key: readability-identifier-naming.ClassMemberSuffix, value: _ } |
| 74 |
- { key: readability-identifier-naming.PrivateMemberSuffix, value: _ } |
| 75 |
- { key: readability-identifier-naming.ProtectedMemberSuffix, value: _ } |
| 76 |
- { key: readability-identifier-naming.EnumConstantCase, value: UPPER_CASE } |
| 77 |
- { key: readability-identifier-naming.ConstexprVariableCase, value: CamelCase } |
| 78 |
- { key: readability-identifier-naming.GlobalConstantCase, value: CamelCase } |
| 79 |
- { key: readability-identifier-naming.MemberConstantCase, value: CamelCase } |
| 80 |
- { key: readability-identifier-naming.StaticConstantCase, value: CamelCase } |
| 81 |
|
| 82 |
# Use <cstdint> fixed-width integer types instead of short, long and long long |
| 83 |
- { key: google-runtime-int.UnsignedTypePrefix, value: "uint" } |
| 84 |
- { key: google-runtime-int.SignedTypePrefix, value: "int" } |
| 85 |
- { key: google-runtime-int.TypeSuffix, value: "_t" } |
| 86 |
|
| 87 |
# `int8_t` aren't used as chars, disable misleading warning. |
| 88 |
- { key: bugprone-signed-char-misuse.CharTypdefsToIgnore, value: "int8_t" } |
| 89 |
|
| 90 |
# Single char loop counters are OK. |
| 91 |
- { key: readability-identifier-length.MinimumLoopCounterNameLength, value: 1 } |