Skip to content

Commit f817f29

Browse files
authored
Merge pull request #22195 from maribu/clang-tidy/disable-magic-number-warning
.clang-tidy: disable warning about magic numbers
2 parents 49d83e9 + 8d6b1ba commit f817f29

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

.clang-tidy

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,23 @@
3939
# Fine Tuning
4040
# -----------
4141
#
42-
# - readability-function-cognitive-complexity.IgnoreMacros: 'true':
43-
# Otherwise the use of `DEBUG()...` will be penalized, even though it
44-
# helps both in debugging and to document the code.
42+
# - readability-function-cognitive-complexity.IgnoreMacros: `true`:
43+
# Otherwise the use of `DEBUG()` will be penalized, even though it
44+
# helps both with debugging and with documenting the code.
45+
# - readability-identifier-length:
46+
# Disabled because of too many false positives.. E.g., `fd` for file
47+
# descriptors or `id` for IDs will be flagged, but are sensible variables
48+
# names when the scope is the function body
49+
# - readability-magic-numbers:
50+
# Disabled because of too many false positives. E.g. in
51+
# ```
52+
# size_t byte_pos = bitpos / 8;
53+
# size_t byte_mask = 1U << (bitpos & 7);
54+
# ```
55+
# the numbers `8` and `7` are considered to be magic, but the code is
56+
# still self-explanatory. Adding `#define BITS_PER_BYTE 8` and
57+
# `#define BIT_POS_IN_BYTE_MASK 7` to silence the warning would not
58+
# improve the readability here, but instead reduce it.
4559
#
4660
# Warning
4761
# -------
@@ -60,6 +74,7 @@ Checks: "clang-analyzer-*,
6074
-bugprone-reserved-identifier,
6175
-bugprone-easily-swappable-parameters,
6276
-readability-identifier-length,
77+
-readability-magic-numbers
6378
"
6479
WarningsAsErrors: "bugprone-*,
6580
portability-*,

dist/tools/ci/can_fast_ci_run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
[re.compile(r"^(drivers\/include\/.*|sys\/include\/.*)$"), "public-headers"],
2323
[re.compile(r"^(Kconfig|kconfigs\/.*|pkg\/Kconfig|sys\/Kconfig|drivers\/Kconfig)$"), "kconfig"],
2424
[re.compile(r"^(.*\.cff|doc\/.*|.*\.md|.*\.txt)$"), "doc"],
25-
[re.compile(r"^(CODEOWNERS|.mailmap|.gitignore|.github\/.*)$"), "git"],
25+
[re.compile(r"^(CODEOWNERS|\.mailmap|\.gitignore|\.github|\.gitattributes)$"), "git"],
2626
[re.compile(r"^(\.murdock|dist\/ls\/.*|\.drone.yml)$"), "ci-murdock"],
2727
[re.compile(r"^(\.bandit|\.drone.yml)$"), "ci-other"],
28-
[re.compile(r"^(dist\/.*|Vagrantfile)$"), "tools"],
28+
[re.compile(r"^(dist\/.*|Vagrantfile|\.clang-format|\.clang-tidy)$"), "tools"],
2929
]
3030

3131
REGEX_MODULE = re.compile(r"^(boards\/common|core|cpu|drivers|sys)\/")

0 commit comments

Comments
 (0)