From 3eeca784d21dd38f633e3a135b7c9fd2210ebac2 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Sun, 19 Sep 2021 15:46:18 -0600 Subject: [PATCH] Meta: Add basic clang-tidy configuration Add a basic clang-tidy configuration that enables checks from the following categories: - bugprone - cert - clang-analyzer - concurrency - misc - performance - portability - readability The noisiest rules that have conflicts with the project style guide or accepted practices have been turned off. There's absolutely more work to be done here before we could consider setting any of these warnings as errors and enforcing them in CI, but committing a project clang-tidy configuration should help the rules become more visible and let other contributors take a crack at tweaking rules and/or finding possible bugs. Sadly the cpp-core-guidelines and modernize categories are very, very noisy. If we want to enable rules from these categories, they would need to be on a rule by rule basis. --- .clang-tidy | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ AK/.clang-tidy | 7 +++++++ 2 files changed, 55 insertions(+) create mode 100644 .clang-tidy create mode 100644 AK/.clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 00000000000..489819d4d79 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,48 @@ +--- +# Globally Disabled checks: +# +# bugprone-easily-swappable-parameters: This warning is loud with no clear advice on how to fix the potential problem +# FIXME: bugprone-macro-parentheses: Enable with clang-tidy-14 when NOLINTBEGIN/NOLINTEND are available for code generating macros +# bugprone-reserved-identifier: LibC headers that show up in the header filter are part of "the implementation" +# cert-dcl37-c: Alias for bugprone-reserved-identifier +# cert-dcl51-cpp: Alias for bugprone-reserved-identifier +# cert-dcl21-cpp: No reference to this rule exists on Carnegie Mellon's SEI CERT C++ Confluence. And the suggestion is unusual +# FIXME: misc-non-private-member-variables-in-classes: Audit uses of protected member variables to see if they really need to be protected +# performance-noexcept-move-constructor: The project does not use exceptions, so there are no such optimizations available +# performance-no-int-to-ptr: This rule flags every pointer to integer cast, which gets quite noisy. Should only be enabled on a case-by-case basis +# readability-braces-around-statements: Redundant braces around single-line conditions is against project style +# readability-magic-numbers: This check is very noisy in the codebase, especially in AK. +# readability-named-parameter: We frequently omit parameter names to work around -Wunused-parameter +# FIXME: readability-uppercase-literal-suffix: Enable this check, the rationale is solid but the findings are numerous +# +Checks: > + -*, + bugprone-*, + cert-*, + clang-analyzer-*, + concurrency-*, + misc-*, + performance-*, + portability-*, + readability-*, + -bugprone-easily-swappable-parameters, + -bugprone-macro-parentheses, + -bugprone-reserved-identifier,-cert-dcl37-c,-cert-dcl51-cpp, + -cert-dcl21-cpp, + -misc-non-private-member-variables-in-classes, + -performance-noexcept-move-constructor, + -performance-no-int-to-ptr, + -readability-braces-around-statements, + -readability-magic-numbers, + -readability-named-parameter, + -readability-uppercase-literal-suffix, +WarningsAsErrors: '' +HeaderFilterRegex: 'AK|Userland|Kernel|Tests' +FormatStyle: none +CheckOptions: + - key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic + value: true + - key: readability-implicit-bool-conversion.AllowPointerConditions + value: true + - key: readability-function-cognitive-complexity.Threshold + value: 100 # FIXME: Lower this (30? 50?), and refactor complex functions diff --git a/AK/.clang-tidy b/AK/.clang-tidy new file mode 100644 index 00000000000..3c058300639 --- /dev/null +++ b/AK/.clang-tidy @@ -0,0 +1,7 @@ +--- +# Disabled checks: +# +# misc-unused-using-decls: AK exports all public names into the global namespace per project style +# +Checks: '-misc-unused-using-decls' +InheritParentConfig: true