Skip to content

Commit

Permalink
clang-tidy: add config.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ericonr committed Jan 15, 2025
1 parent 2192e40 commit 0701ce6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -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: "*"

0 comments on commit 0701ce6

Please sign in to comment.