1- # Apply to ALL headers (empty = no restriction)
2- HeaderFilterRegex : ' .*'
3-
4- # Treat warnings as errors (optional but recommended for CI)
5- # WarningsAsErrors: '*'
6- WarningsAsErrors : ' '
1+ ---
2+ # Configure clang-tidy for this project.
73
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-concat-nested-namespaces: clang-tidy recommends
14+ # `namespace google::cloud {}` over `namespace google { namespace cloud { } }`
15+ # We need to support C++14, which does not supported nested namespaces.
16+ #
17+ # --modernize-use-nodiscard: clang-tidy recommends adding a nodiscard annotation
18+ # to functions where the return value should not be ignored.
19+ # We need to support C++14, which does not supported the annotation.
20+ #
21+ # -modernize-return-braced-init-list: We think removing typenames and using
22+ # only braced-init can hurt readability.
23+ #
24+ # -modernize-avoid-c-arrays: We only use C arrays when they seem to be the
25+ # right tool for the job, such as `char foo[] = "hello"`. In these cases,
26+ # avoiding C arrays often makes the code less readable, and std::array is
27+ # not a drop-in replacement because it doesn't deduce the size.
28+ #
29+ # -modernize-type-traits: clang-tidy recommands using c++17 style variable
30+ # templates. We will enable this check after we moved to c++17.
31+ #
32+ # -modernize-unary-static-assert: clang-tidy asks removing empty string in
33+ # static_assert(), the check is only applicable for c++17 and later code.
34+ # We will enable this check after we moved to c++17.
35+ #
36+ # -performance-move-const-arg: This warning requires the developer to
37+ # know/care more about the implementation details of types/functions than
38+ # should be necessary. For example, `A a; F(std::move(a));` will trigger a
39+ # warning IFF `A` is a trivial type (and therefore the move is
40+ # meaningless). It would also warn if `F` accepts by `const&`, which is
41+ # another detail that the caller need not care about.
42+ #
43+ # -performance-avoid-endl: we would like to turn this on, but there are too
44+ # many legitimate uses in our samples.
45+ #
46+ # -performance-enum-size: Smaller enums may or not may be faster, it depends on
47+ # the architechture. If data size was a consideration, we might decide to
48+ # enable the warnings.
49+ #
50+ # -readability-redundant-declaration: A friend declaration inside a class
51+ # counts as a declaration, so if we also declare that friend outside the
52+ # class in order to document it as part of the public API, that will
53+ # trigger a redundant declaration warning from this check.
54+ #
55+ # -readability-avoid-return-with-void-value: We believe this is idiomatic
56+ # and saves typing, and the intent is obvious.
57+ #
58+ # -readability-function-cognitive-complexity: too many false positives with
59+ # clang-tidy-12. We need to disable this check in macros, and that setting
60+ # only appears in clang-tidy-13.
61+ #
62+ # -bugprone-narrowing-conversions: too many false positives around
63+ # `std::size_t` vs. `*::difference_type`.
64+ #
65+ # -bugprone-easily-swappable-parameters: too many false positives.
66+ #
67+ # -bugprone-implicit-widening-of-multiplication-result: too many false positives.
68+ # Almost any expression of the form `2 * variable` or `long x = a_int * b_int;`
69+ # generates an error.
70+ #
71+ # -bugprone-unchecked-optional-access: too many false positives in tests.
72+ # Despite what the documentation says, this warning appears after
73+ # `ASSERT_TRUE(variable)` or `ASSERT_TRUE(variable.has_value())`.
74+ #
75+ # TODO(#14162): Enable clang-tidy checks. We initially omitted these checks
76+ # because they require large cleanup efforts or were blocking the clang-tidy
77+ # X update.
878Checks : >
979 -*,
10- clang-diagnostic-*,
11- modernize-*,
12- -modernize-use-trailing-return-type,
13- -modernize-use-auto,
14- cppcoreguidelines-*,
15- -cppcoreguidelines-owning-memory,
16- -cppcoreguidelines-pro-type-vararg,
17- -cppcoreguidelines-avoid-magic-numbers,
80+ abseil-*,
1881 bugprone-*,
82+ google-*,
83+ misc-*,
84+ modernize-*,
1985 performance-*,
86+ portability-*,
2087 readability-*,
21- -readability-magic-numbers,
88+ -bugprone-exception-escape,
89+ -google-readability-braces-around-statements,
90+ -google-readability-namespace-comments,
91+ -google-runtime-references,
92+ -misc-non-private-member-variables-in-classes,
93+ -misc-const-correctness,
94+ -misc-include-cleaner,
95+ -modernize-return-braced-init-list,
96+ -modernize-use-trailing-return-type,
97+ -modernize-concat-nested-namespaces,
98+ -modernize-use-nodiscard,
99+ -modernize-avoid-c-arrays,
100+ -modernize-type-traits,
101+ -modernize-unary-static-assert,
102+ -performance-move-const-arg,
103+ -performance-avoid-endl,
104+ -performance-enum-size,
105+ -readability-braces-around-statements,
22106 -readability-identifier-length,
23- misc-*,
24- -misc-unused-parameters
25-
26- CheckOptions :
27- - key : readability-identifier-naming.NamespaceCase
28- value : lower_case
29-
30- - key : readability-identifier-naming.ClassCase
31- value : CamelCase
32-
33- - key : readability-identifier-naming.StructCase
34- value : CamelCase
35-
36- - key : readability-identifier-naming.FunctionCase
37- value : lower_case
107+ -readability-magic-numbers,
108+ -readability-named-parameter,
109+ -readability-redundant-declaration,
110+ -readability-avoid-return-with-void-value,
111+ -readability-function-cognitive-complexity,
112+ -bugprone-narrowing-conversions,
113+ -bugprone-easily-swappable-parameters,
114+ -bugprone-inc-dec-in-conditions,
115+ -bugprone-implicit-widening-of-multiplication-result,
116+ -bugprone-unchecked-optional-access,
117+ -bugprone-unused-local-non-trivial-variable,
118+ -bugprone-unused-return-value
38119
39- - key : readability-identifier-naming.VariableCase
40- value : lower_case
120+ # Turn all the warnings from the checks above into errors.
121+ WarningsAsErrors : " * "
41122
42- - key : readability-identifier-naming.MemberCase
43- value : lower_case
123+ HeaderFilterRegex : " (google/cloud/|generator/).*\\ .h$"
44124
45- - key : modernize-use-nullptr.NullMacros
46- value : ' NULL'
125+ CheckOptions :
126+ - { key: readability-identifier-naming.NamespaceCase, value: lower_case }
127+ - { key: readability-identifier-naming.ClassCase, value: CamelCase }
128+ - { key: readability-identifier-naming.StructCase, value: CamelCase }
129+ - { key: readability-identifier-naming.TemplateParameterCase, value: CamelCase }
130+ - { key: readability-identifier-naming.FunctionCase, value: aNy_CasE }
131+ - { key: readability-identifier-naming.VariableCase, value: lower_case }
132+ - { key: readability-identifier-naming.ClassMemberCase, value: lower_case }
133+ - { key: readability-identifier-naming.ClassMemberSuffix, value: _ }
134+ - { key: readability-identifier-naming.PrivateMemberSuffix, value: _ }
135+ - { key: readability-identifier-naming.ProtectedMemberSuffix, value: _ }
136+ - { key: readability-identifier-naming.EnumConstantCase, value: CamelCase }
137+ - { key: readability-identifier-naming.EnumConstantPrefix, value: k }
138+ - { key: readability-identifier-naming.ConstexprVariableCase, value: CamelCase }
139+ - { key: readability-identifier-naming.ConstexprVariablePrefix, value: k }
140+ - { key: readability-identifier-naming.GlobalConstantCase, value: CamelCase }
141+ - { key: readability-identifier-naming.GlobalConstantPrefix, value: k }
142+ - { key: readability-identifier-naming.MemberConstantCase, value: CamelCase }
143+ - { key: readability-identifier-naming.MemberConstantPrefix, value: k }
144+ - { key: readability-identifier-naming.StaticConstantCase, value: CamelCase }
145+ - { key: readability-identifier-naming.StaticConstantPrefix, value: k }
146+ - { key: readability-implicit-bool-conversion.AllowIntegerConditions, value: 1 }
147+ - { key: readability-implicit-bool-conversion.AllowPointerConditions, value: 1 }
148+ - { key: readability-function-cognitive-complexity.IgnoreMacros, value: 1 }
0 commit comments