From 888721ea12c7bfdba9c3a33a84879bdd964f9d7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Fri, 16 Sep 2022 07:16:35 +0200 Subject: [PATCH] disabled some clang-tidy checks which are not necessary and slow down the analysis / documented disabled checks (#4468) * added `clang-tidy.md` to document our `.clang-tidy` configuration * disabled some clang-tidy checks which are not necessary and slow down the analysis --- .clang-tidy | 2 +- clang-tidy.md | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 clang-tidy.md diff --git a/.clang-tidy b/.clang-tidy index 13451e0d6..6852de45b 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,5 @@ --- -Checks: '*,-abseil-*,-altera-*,-android-*,-boost-*,-cert-*,-cppcoreguidelines-*,-darwin-*,-fuchsia-*,-google-*,-hicpp-*,-linuxkernel-*,-llvm-*,-llvmlibc-*,-mpi-*,-objc-*,-openmp-*,-zircon-*,-readability-braces-around-statements,-readability-magic-numbers,-bugprone-macro-parentheses,-readability-isolate-declaration,-readability-function-size,-modernize-use-trailing-return-type,-readability-implicit-bool-conversion,-readability-uppercase-literal-suffix,-modernize-use-auto,-readability-else-after-return,-modernize-use-default-member-init,-readability-named-parameter,-readability-redundant-member-init,-performance-faster-string-find,-modernize-avoid-c-arrays,-modernize-use-equals-default,-readability-container-size-empty,-readability-simplify-boolean-expr,-bugprone-branch-clone,-bugprone-narrowing-conversions,-modernize-raw-string-literal,-readability-convert-member-functions-to-static,-modernize-loop-convert,-readability-const-return-type,-performance-unnecessary-value-param,-modernize-return-braced-init-list,-performance-inefficient-string-concatenation,-misc-throw-by-value-catch-by-reference,-readability-avoid-const-params-in-decls,-readability-non-const-parameter,-misc-non-private-member-variables-in-classes,-bugprone-suspicious-string-compare,-clang-analyzer-*,-bugprone-signed-char-misuse,-misc-no-recursion,-readability-use-anyofallof,-performance-no-automatic-move,-bugprone-suspicious-include,-modernize-replace-random-shuffle,-readability-function-cognitive-complexity,-readability-redundant-access-specifiers,-performance-noexcept-move-constructor,-concurrency-mt-unsafe,-bugprone-easily-swappable-parameters,-readability-suspicious-call-argument,-readability-identifier-length,-readability-container-data-pointer,-bugprone-assignment-in-if-condition,-misc-const-correctness' +Checks: '*,-abseil-*,-altera-*,-android-*,-boost-*,-cert-*,-cppcoreguidelines-*,-darwin-*,-fuchsia-*,-google-*,-hicpp-*,-linuxkernel-*,-llvm-*,-llvmlibc-*,-mpi-*,-objc-*,-openmp-*,-zircon-*,-readability-braces-around-statements,-readability-magic-numbers,-bugprone-macro-parentheses,-readability-isolate-declaration,-readability-function-size,-modernize-use-trailing-return-type,-readability-implicit-bool-conversion,-readability-uppercase-literal-suffix,-modernize-use-auto,-readability-else-after-return,-modernize-use-default-member-init,-readability-named-parameter,-readability-redundant-member-init,-performance-faster-string-find,-modernize-avoid-c-arrays,-modernize-use-equals-default,-readability-container-size-empty,-readability-simplify-boolean-expr,-bugprone-branch-clone,-bugprone-narrowing-conversions,-modernize-raw-string-literal,-readability-convert-member-functions-to-static,-modernize-loop-convert,-readability-const-return-type,-performance-unnecessary-value-param,-modernize-return-braced-init-list,-performance-inefficient-string-concatenation,-misc-throw-by-value-catch-by-reference,-readability-avoid-const-params-in-decls,-readability-non-const-parameter,-misc-non-private-member-variables-in-classes,-bugprone-suspicious-string-compare,-clang-analyzer-*,-bugprone-signed-char-misuse,-misc-no-recursion,-readability-use-anyofallof,-performance-no-automatic-move,-bugprone-suspicious-include,-modernize-replace-random-shuffle,-readability-function-cognitive-complexity,-readability-redundant-access-specifiers,-performance-noexcept-move-constructor,-concurrency-mt-unsafe,-bugprone-easily-swappable-parameters,-readability-suspicious-call-argument,-readability-identifier-length,-readability-container-data-pointer,-bugprone-assignment-in-if-condition,-misc-const-correctness,-portability-std-allocator-const,-modernize-deprecated-ios-base-aliases,-bugprone-unchecked-optional-access,-modernize-replace-auto-ptr,-readability-identifier-naming,-portability-simd-intrinsics' WarningsAsErrors: '*' CheckOptions: - key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic diff --git a/clang-tidy.md b/clang-tidy.md new file mode 100644 index 000000000..56ae37a40 --- /dev/null +++ b/clang-tidy.md @@ -0,0 +1,156 @@ +# clang-tidy + +Below are the reasoning why certain checks are (currently) disabled for out code base + +## Externals + +We do not perform static analysis of the source of the external libraries. `simplecpp` has its own CI with a clang-tidy workflow. + +## Disabled Checks + +`abseil-*`
+`altera-*`
+`android-*`
+`boost-*`
+`darwin-*`
+`fuchsia-*`
+`linuxkernel-*`
+`llvm-*`
+`llvmlibc-*`
+`mpi-*`
+`objc-*`
+`openmp-*`
+`zircon-*`
+ +These are disabled since the platforms/libraries in question are not targeted by us. + +`cert-*`
+`cppcoreguidelines-*`
+`google-*`
+`hicpp-*`
+ +These are coding guidelines we do not follow. Some of the checks might be explicitly enabled though. + +`readability-braces-around-statements`
+`readability-isolate-declaration`
+`modernize-use-trailing-return-type`
+`modernize-use-auto`
+`readability-uppercase-literal-suffix`
+`readability-else-after-return`
+`modernize-use-default-member-init`
+`readability-identifier-length`
+ +These do not relect the style we are (currently) enforcing. + +`readability-function-size`
+`readability-function-cognitive-complexity`
+ +We are not interesting in the size/complexity of a function. + +`readability-magic-numbers`
+`readability-redundant-member-init`
+`readability-simplify-boolean-expr`
+ +These do not (always) increase readbility. + +`bugprone-macro-parentheses`
+`readability-implicit-bool-conversion`
+`readability-named-parameter`
+ +To be documented. + +`performance-faster-string-find`
+`bugprone-narrowing-conversions`
+`performance-no-automatic-move`
+ +It was decided not to apply these. + +`modernize-use-equals-default`
+`modernize-loop-convert`
+ +These might change the behavior of code which might not be intended (need to file an upstream issue) + +`modernize-raw-string-literal`
+ +This leads to a mismatch of raw string literals and regular ones and does reduce the readability. + +`readability-convert-member-functions-to-static`
+ +Disabled because of false postives with Qt `slot` methods (see https://github.com/llvm/llvm-project/issues/57520). + +`-clang-analyzer-*`
+ +Disable because of false positives (needs to file an upstream bug report). + +`misc-non-private-member-variables-in-classes`
+ +We actively use this. + +`misc-no-recursion`
+ +Leads to lots of "false positives". This seem to enforce a coding guidelines of certain codebases. + +`readability-use-anyofallof`
+ +We currently don't even apply our own `useStlAlgorithm` findings. + +`bugprone-easily-swappable-parameters`
+ +This produces a lot of noise and they are not fixable that easily. + +`readability-container-data-pointer`
+ +Disable because of false positives and inconsistent warnings (need to file an upstream bug report). + +`misc-const-correctness`
+ +Work in progress. + +`bugprone-assignment-in-if-condition`
+ +Is reported for valid patterns we are using. + +`modernize-avoid-c-arrays`
+`readability-container-size-empty`
+`bugprone-branch-clone`
+`readability-const-return-type`
+`performance-unnecessary-value-param`
+`modernize-return-braced-init-list`
+`performance-inefficient-string-concatenation`
+`misc-throw-by-value-catch-by-reference`
+`readability-avoid-const-params-in-decls`
+`readability-non-const-parameter`
+`bugprone-suspicious-string-compare`
+`bugprone-signed-char-misuse`
+`bugprone-suspicious-include`
+`modernize-replace-random-shuffle`
+`readability-redundant-access-specifiers`
+`performance-noexcept-move-constructor`
+`concurrency-mt-unsafe`
+`readability-suspicious-call-argument`
+ +To be evaluated. + +`portability-std-allocator-const`
+ +Only necessary for code which is exclusively compiled with `libc++`. Also disabled for performance reasons - see https://github.com/llvm/llvm-project/issues/57527#issuecomment-1237935132. + +`modernize-deprecated-ios-base-aliases`
+ +Warns about aliases which are removed in C++20. Also disabled for performance reasons - see https://github.com/llvm/llvm-project/issues/57527#issuecomment-1237935132. + +`bugprone-unchecked-optional-access`
+ +We are not using any `optional` implementation. Also disabled for performance reasons - see https://github.com/llvm/llvm-project/issues/57527#issuecomment-1237935132. + +`modernize-replace-auto-ptr`
+ +Still available until C++17. It is unlikely such code will ever be introduced. Also disabled for performance reasons - see https://github.com/llvm/llvm-project/issues/57527#issuecomment-1237935132. + +`readability-identifier-naming`
+ +We are currently using our own `naming.json` to enforce naming schemes. Also disabled for performance reasons - see https://github.com/llvm/llvm-project/issues/57527#issuecomment-1237935132. + +`portability-simd-intrinsics`
+ +We are not using SIMD instructions and it suggests to use `std::experiemental::` features which might not be commonly available. Also disabled for performance reasons - see https://github.com/llvm/llvm-project/issues/57527#issuecomment-1237935132.