From b040a0cc7c98f4d4f538ca66065786d6e3a8d122 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89lo=C3=AFse=20Brosseau?=
<54746458+eloisebrosseau@users.noreply.github.com>
Date: Fri, 13 Dec 2024 10:57:52 -0500
Subject: [PATCH] Add a .clang-tidy to lint the C++ code (#648)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
### Add a .clang-tidy to lint the C++ code
### Summarize your change.
A .clang-tidy was added at the root of the project to lint our C++ code.
We should do the same for commercial RV if everyone is happy with this
one. The formatStyle is set to 'file' so that the changes suggested by
the linter will match the rules in our .clang-format. WarningAsErrors
could be changed to match all or any of the checks if, at one point, we
would want to enforce the respect of a category. HeaderFilterRegex could
be changed if we need to exclude some header files from being lint by
clang-tidy.
### Describe the reason for the change.
Just like we are formatting our code with the .clang-format, we should
also lint it using a .clang-tidy. This is the one I've been using
personally but I think it could be beneficial to others, especially for
code reviews since it would help to avoid having to ask for small
changes that could have been easily catch by a linter. Ideally, we would
also add it to our CI pipeline so that we don't only rely on people
generating a compile_commands.json to use it and making the changes
suggested to the code by the linter. Here's the documentation
### If possible, provide screenshots.
Here's an example of what the linter messages could look like:
Signed-off-by: Éloïse Brosseau
---
.clang-tidy | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
create mode 100644 .clang-tidy
diff --git a/.clang-tidy b/.clang-tidy
new file mode 100644
index 000000000..2bf615398
--- /dev/null
+++ b/.clang-tidy
@@ -0,0 +1,20 @@
+---
+Checks: >
+ bugprone-*,
+ cert-*,
+ clang-diagnostic-*,
+ clang-analyzer-*,
+ concurrency-*,
+ cppcoreguidelines-*,
+ -cppcoreguidelines-pro-type-reinterpret-cast,
+ google-explicit-constructor,
+ misc-*,
+ modernize-*,
+ -modernize-use-trailing-return-type,
+ performance-*,
+ readability-*,
+
+WarningsAsErrors: ''
+HeaderFilterRegex: ''
+FormatStyle: 'file'
+...