From 0701ce6243389ef141826f2c8b780671385843d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Nogueira?= Date: Wed, 8 Jan 2025 17:26:21 -0300 Subject: [PATCH] clang-tidy: add config. The test groups that were added were the ones considered relevant for this project. Test groups used to enforce code style for specific projects and platforms were omitted. The specific tests from the groups in use that had to be removed are explained below: - cppcoreguidelines-avoid-do-while: we use do-while for actual logic, there's no reason to remove it; - cppcoreguidelines-pro-bounds-pointer-arithmetic: pointer arithmetic is necessary in quite a few places. One of those is manipulating argv/argc, where using std::span doesn't add any safety (.at() member function is C++26), and std::vector requires copying; - cppcoreguidelines-pro-type-vararg: we use cstdio extensively; - modernize-use-trailing-return-type: though more modern, this function declaration style isn't widespread, and would conflict with the style used in other projects this one interacts with. It would also increase the barrier to entry for this project; - readability-braces-around-statements: braces are skipped for single statements, which should always be indented (this will be guaranteed by clang-format in the future); - readability-identifier-length: short names for iterator variables and throwaway values, as well as known shorthand (f for FILEs, v for verbose) should be used; - readability-implicit-bool-conversion: treating pointers as bools is a common idiom. We want clang-tidy to verify our own headers, which are under include/modules/ and utils/. We also want clang-tidy-diff, when used, to exit with an error. --- .clang-tidy | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..7bb43f2 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,18 @@ +Checks: "bugprone*,\ + cert-*,\ + clang-analyzer*,\ + concurrency-*,\ + cppcoreguidelines-*,\ + modernize-*,\ + performance-*,\ + readability-*,\ + -cppcoreguidelines-avoid-do-while,\ + -cppcoreguidelines-pro-bounds-pointer-arithmetic,\ + -cppcoreguidelines-pro-type-vararg,\ + -modernize-use-trailing-return-type,\ + -readability-braces-around-statements,\ + -readability-identifier-length,\ + -readability-implicit-bool-conversion" + +HeaderFilterRegex: "(util|modules)/[^/]*\.h" +WarningsAsErrors: "*"