-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy path.clang-tidy
More file actions
110 lines (110 loc) · 4.16 KB
/
Copy path.clang-tidy
File metadata and controls
110 lines (110 loc) · 4.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# Reasoning
# =========
#
# Selection of Checks
# ------------------
#
# Selecting the following general purpose checks relevant for C code:
# - clang-analyzer-* ()
# - bugprone-*
# - readability-*
# - misc-*
#
# Additional checks for other languages or specific to projects/coding standards
# are not used, expected for the Linux kernel coding conventions, as the RIOT
# coding conventions builds upon the Linux coding conventions.
#
# Finally, the following checks are disabled:
# - bugprone-reserved-identifier:
# Too many false positives, as check does not take `static` declaration
# into account
# - bugprone-easily-swappable-parameters:
# This cannot be avoided
# - bugprone-too-small-loop-variable:
# Too many false positives
#
#
# Which Warnings to Raise to Errors
# ---------------------------------
#
# - bugprone-*:
# Avoiding known pitfalls or explicitly adding a magic comment and a
# reasoning for why sticking with a footgun should be doable
# - portability-*:
# Porability issues bite us hard due to the wide varity of board,
# toolchains, standard C libs, etc. we use. So we should avoid them
# where possible
#
#
# Fine Tuning
# -----------
#
# - readability-function-cognitive-complexity.IgnoreMacros: `true`:
# Otherwise the use of `DEBUG()` will be penalized, even though it
# helps both with debugging and with documenting the code.
# - readability-identifier-length:
# Disabled because of too many false positives.. E.g., `fd` for file
# descriptors or `id` for IDs will be flagged, but are sensible variables
# names when the scope is the function body
# - readability-magic-numbers:
# Disabled because of too many false positives. E.g. in
# ```
# size_t byte_pos = bitpos / 8;
# size_t byte_mask = 1U << (bitpos & 7);
# ```
# the numbers `8` and `7` are considered to be magic, but the code is
# still self-explanatory. Adding `#define BITS_PER_BYTE 8` and
# `#define BIT_POS_IN_BYTE_MASK 7` to silence the warning would not
# improve the readability here, but instead reduce it.
# - readability-implicit-bool-conversion:
# Conversion to bool is well defined and happens in a lot of places. With
# this enabled, the source code in the editor lights up like a christmas
# tree due to the amount of warnings.
# - bugprone-narrowing-conversions:
# This warning is too aggressive: Even when returning e.g. a compile time
# constant that is known to fit the return type of a function, a simple
# `return FOO;` will get a warning. But using `return (some_type)FOO;` is
# not more readable and explicit casts actively harm, as they mute
# a lot of compiler diagnostics.
# - bugprone-assignment-in-if-condition:
# This is idomatic C and not disallowed or discouraged by the coding
# convention:
# ```c
# if ((err = something()) < 0) {
# return err;
# }
# ```
# So let's not warn about it, while it still is considered acceptable.
# - readability-isolate-declaration:
# Multiple declaration in a single line is not disallowed by the coding
# convention used a lot in the code base. So let's allow it.
# Warning
# -------
#
# This configuration file is rather new and may enable a few warnings with a
# low signal-to-noise ratio are may not enable checks that would be exteremely
# helpful. If you modify this file to improve your experience, please consider
# upstreaming the changes.
---
Checks: "bugprone-*,
clang-analyzer-*,
linuxkernel-*,
misc-*,
portability-*,
readability-*,
-bugprone-assignment-in-if-condition,
-bugprone-easily-swappable-parameters,
-bugprone-narrowing-conversions,
-bugprone-reserved-identifier,
-readability-identifier-length,
-readability-implicit-bool-conversion,
-readability-isolate-declaration,
-readability-magic-numbers,
"
WarningsAsErrors: "bugprone-*,
portability-*,
"
HeaderFilterRegex: ''
FormatStyle: file
CheckOptions:
readability-function-cognitive-complexity.IgnoreMacros: 'true'