mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-25 00:30:50 +08:00
ci(clang-tidy): stop false positives in the inline review comments (#29013)
* ci(clang-tidy): stop false positives in the inline review comments Of the 828 inline comments the clang-tidy job posted on 98 PRs since May, only 328 were unique: COMMENT reviews can't be dismissed, so every push posted every finding again. Most of the rest were artifacts of how the diff step runs: - It parses against the test build dir, which is only configured, so the uORB, events and parameter headers don't exist and every TU stops at a missing include. clang-tidy then reports on the half-parsed AST: events::send<T>(...) as a chained comparison, sizeof on uORB arrays as sizeof of a pointer. - It parses every changed .h on its own as C++, including board configs, NuttX headers and headers shared with C. The gating run never lints .h. - .clang-tidy disabled macro-parentheses, incorrect-roundings and misplaced-widening-cast under their old misc- names, which clang-tidy 18 no longer knows, so all three were on. Generate the test dir's headers, skip .h and board/NuttX files, drop clang-diagnostic-error (the build jobs report real compile errors), skip findings already posted on the PR, and disable four checks that only produced noise: googletest underscore names, virtual-class-destructor on gtest fixtures and singletons, suspicious-call-argument, and not-null-terminated-result on binary packet buffers. Assisted-by: Claude:claude-opus-5-5 * ci(clang-tidy): keep the gating checks and skip the fuzztest header .clang-tidy also configures the gating run, which enabled incorrect-roundings, macro-parentheses and virtual-class-destructor on purpose, with code fixes. Drop the stale misc- names instead of renaming them, and turn virtual-class-destructor, suspicious-call-argument and not-null-terminated-result off for the inline comments only. Header generation also built fuzztest's json_grammar.h, which pulls in abseil and the antlr4 runtime: 336 ninja edges and 39 s in CI instead of 22 edges and 4 s. Match already-posted comments on the line too, so a second finding with the same message elsewhere in a file is still posted. Drop only headers under boards/ and platforms/nuttx/, so SITL's own board sources are still linted. Assisted-by: Claude:claude-opus-5-5
This commit is contained in:
1 parent
dfa1d03ea1
commit
a4697ed08e
4 files changed
+70
-27
No files matched your search
@@ -95,7 +95,7 @@ jobs:
|
||||
|
||||
# Two clang build directories, prepared one after the other so their
|
||||
# configures never fetch submodules at the same time:
|
||||
# - build/px4_sitl_default-clang-test: configure-only, BUILD_TESTING=ON
|
||||
# - build/px4_sitl_default-clang-test: configure + generated headers only, BUILD_TESTING=ON
|
||||
# (used by clang-tidy-diff-18.py so test files are in the
|
||||
# compilation database with resolved gtest/fuzztest includes)
|
||||
# - build/px4_sitl_default-clang: full build, BUILD_TESTING=OFF
|
||||
@@ -104,6 +104,20 @@ jobs:
|
||||
- name: Configure clang SITL with tests
|
||||
run: make px4_sitl_default-clang-test
|
||||
|
||||
# The test build dir is never built, so generate its headers (uORB
|
||||
# topics, events, parameters, mavlink, ...). Without them every TU
|
||||
# stops at a missing include and clang-tidy-diff reports on the
|
||||
# half-parsed AST, e.g. events::send<T>(...) as a chained comparison.
|
||||
# fuzztest's json_grammar.h is skipped: generating it builds abseil
|
||||
# and the antlr4 runtime, and no PX4 code includes it.
|
||||
- name: Generate headers for clang SITL with tests
|
||||
working-directory: build/px4_sitl_default-clang-test
|
||||
shell: bash
|
||||
run: |
|
||||
ninja -t targets all \
|
||||
| awk -F': ' '$2 == "CUSTOM_COMMAND" && $1 ~ /\.(h|hpp)$/ && $1 !~ /^(\/|test\/fuzztest\/)/ {print $1}' \
|
||||
| xargs -r ninja
|
||||
|
||||
- name: Build clang SITL
|
||||
run: make -j$(nproc) px4_sitl_default-clang
|
||||
|
||||
@@ -126,9 +140,13 @@ jobs:
|
||||
--build-dir build/px4_sitl_default-clang-test \
|
||||
--base-ref origin/${{ github.base_ref }} \
|
||||
--out pr-review/diff.patch
|
||||
# The -checks list turns checks off for these comments only; the
|
||||
# gating run above keeps them. Here they also lint test code, where
|
||||
# they flag gtest fixtures and binary packet buffers.
|
||||
if [ -s pr-review/diff.patch ]; then
|
||||
clang-tidy-diff-18.py -p1 \
|
||||
-path build/px4_sitl_default-clang-test \
|
||||
-checks=-cppcoreguidelines-virtual-class-destructor,-readability-suspicious-call-argument,-bugprone-not-null-terminated-result \
|
||||
-export-fixes pr-review/fixes.yml \
|
||||
-j0 < pr-review/diff.patch || true
|
||||
else
|
||||
|
||||
Reference in new issue
Block a user