Skip to content

Commit 94f0a34

Browse files
authored
Merge pull request #1286 from NickeZ/nickez/clang-tidy
DX: Move clang-tidy config to config file
2 parents 6e42361 + fc17743 commit 94f0a34

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

.ci/check-tidy

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ for dir in build build-build; do
3131
exit 1
3232
fi
3333

34-
# Remove flags unknown to tidy
35-
sed -i 's/-mcpu=cortex-m4//g; s/-mfloat-abi=softfp//g; s/-mlong-calls//g; s/-mthumb//g; s/--specs=nano.specs//g; s/--specs=nosys.specs//g;
36-
s/-Wno-cast-function-type//g; s/-mfpu=fpv4-sp-d16//g; s/-Wformat-signedness//g' ${dir}/compile_commands.json
37-
3834
# Only check our files
3935
SOURCES1=$(git --no-pager diff --diff-filter=d --name-only ${TARGET_BRANCH} HEAD |\
4036
grep -v -E "(^src/(drivers|ui/fonts)|.*ugui.*|.*base32.*)" |\
@@ -55,6 +51,5 @@ for dir in build build-build; do
5551
fi
5652

5753
echo "Checking $(echo ${SOURCES} | wc -w) files with clang-tidy"
58-
# The list of tidy checks must stay in sync with scripts/tidy
59-
${CLANGTIDY} -quiet -p ${dir} -checks=-*,clang-analyzer-*,-clang-analyzer-cplusplus*,bugprone-*,performance-*,portability-*,readability-*,-readability-braces-around-statements,-readability-magic-numbers,-readability-isolate-declaration,-readability-identifier-length,-readability-function-cognitive-complexity,-bugprone-reserved-identifier,-bugprone-easily-swappable-parameters,-bugprone-narrowing-conversions,-performance-no-int-to-ptr,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-readability-avoid-unconditional-preprocessor-if -warnings-as-errors=* -header-filter '.*' ${SOURCES}
54+
${CLANGTIDY} --quiet -p ${dir} --warnings-as-errors='*' ${SOURCES}
6055
done

.clang-tidy

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Checks: >-
2+
clang-analyzer-*,
3+
-clang-analyzer-cplusplus*,
4+
bugprone-*,
5+
performance-*,
6+
portability-*,
7+
readability-*,
8+
-readability-braces-around-statements,
9+
-readability-magic-numbers,
10+
-readability-isolate-declaration,
11+
-readability-identifier-length,
12+
-readability-function-cognitive-complexity,
13+
-bugprone-reserved-identifier,
14+
-bugprone-easily-swappable-parameters,
15+
-bugprone-narrowing-conversions,
16+
-performance-no-int-to-ptr,
17+
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
18+
-readability-avoid-unconditional-preprocessor-if
19+
HeaderFilterRegex: '.*'
20+
ExtraArgs:
21+
- -Wno-unknown-warning-option
22+
- -Qunused-arguments

scripts/tidy

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set -e
88
# Exit on pipe fail
99
set -o pipefail
1010

11-
CLANGTIDY=${CLANGTIDY:-clang-tidy-8}
11+
CLANGTIDY=${CLANGTIDY:-clang-tidy-18}
1212
command -v ${CLANGTIDY} >/dev/null 2>&1 || { echo >&2 "${CLANGTIDY} is missing"; exit 1; }
1313

1414
JQ=${JQ:-jq}
@@ -24,15 +24,11 @@ for dir in build build-build; do
2424
if ! test -d ${dir}; then
2525
continue
2626
fi
27-
# Filter out some commands that are not understood by clang-tidy
28-
sed -i 's/-mcpu=cortex-m4//g; s/-mfloat-abi=softfp//g; s/-mlong-calls//g; s/-mthumb//g;
29-
s/-Wno-cast-function-type//g; s/-mfpu=fpv4-sp-d16//g; s/-Wformat-signedness//g' ${dir}/compile_commands.json
3027

3128
# Exclude drivers and external for now. We get the base file set from compile_commands.json, as
3229
# clang-tidy unfortunately tries to lint a provided source anyway even if it is not part of the
3330
# build.
3431
SOURCES=$(cat ${dir}/compile_commands.json | ${JQ} 'map_values(.file) | .[]' | grep -v -e '/drivers/' -e '/external/' -e '/test/unit-test/u2f/' -e '/build/' -e '/build-build/' | sort | uniq | xargs echo)
3532

36-
# The list of tidy checks must stay in sync with .ci/check-tidy
37-
${CLANGTIDY} -quiet -p ${dir} -checks=-*,clang-analyzer-*,-clang-analyzer-cplusplus*,bugprone-*,performance-*,portability-*,readability-*,-readability-braces-around-statements,-readability-magic-numbers,-readability-isolate-declaration -warnings-as-errors=* -header-filter '.*' ${SOURCES}
33+
${CLANGTIDY} -quiet -p ${dir} ${SOURCES}
3834
done

0 commit comments

Comments
 (0)