Skip to content

fix(clang-tidy): re-enable clang-diagnostic-unused-but-set-variable#12564

Open
vish0012 wants to merge 1 commit intoautowarefoundation:mainfrom
vish0012:fix/clang-tidy-unused-but-set-variable
Open

fix(clang-tidy): re-enable clang-diagnostic-unused-but-set-variable#12564
vish0012 wants to merge 1 commit intoautowarefoundation:mainfrom
vish0012:fix/clang-tidy-unused-but-set-variable

Conversation

@vish0012
Copy link
Copy Markdown
Contributor

Re-enables clang-diagnostic-unused-but-set-variable in .clang-tidy-ci.

The check was suppressed in #12431 with 1 reported error. This PR fixes the affected package.

Refs #12450

Fixes

autoware_motion_velocity_obstacle_slow_down_module

find_reach_time() used an infinite for loop with a loop variable i, but i was never used. The actual warning counter is already handled by the existing iter variable.

This PR removes the unused loop variable by changing:

for (int i = 0;; i++) {

to:

for (;;) {

This keeps the behavior unchanged.

How to reproduce

colcon build --packages-up-to autoware_motion_velocity_obstacle_slow_down_module \
  --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=1

run-clang-tidy -p build/ \
  -config="$(cat src/autoware_universe/.clang-tidy-ci)" \
  -export-fixes /tmp/clang-tidy-result/fixes.yaml \
  -j $(nproc) \
  autoware_motion_velocity_obstacle_slow_down_module \
  > /tmp/clang-tidy-result/report.log 2>&1

Check the target errors:

grep -n "unused-but-set-variable" /tmp/clang-tidy-result/report.log | grep "error:" || echo "0 target errors"

Result

Before: 1 target error

obstacle_slow_down_module.cpp:95:12: error: variable 'i' set but not used [clang-diagnostic-unused-but-set-variable]

After: 0 target errors

0 target errors

Note

Local run-clang-tidy still reports unrelated Boost system-header diagnostics from /usr/include/boost/... under clang-diagnostic-enum-constexpr-conversion. Those diagnostics are unrelated to this PR and were not modified.

Signed-off-by: Vishal Chauhan <40782713+vish0012@users.noreply.github.com>
@vish0012 vish0012 requested a review from mitsudome-r May 11, 2026 01:23
@github-actions github-actions Bot added the component:planning Route planning, decision-making, and navigation. (auto-assigned) label May 11, 2026
@github-actions
Copy link
Copy Markdown

Thank you for contributing to the Autoware project!

🚧 If your pull request is in progress, switch it to draft mode.

Please ensure:

@vish0012 vish0012 added the run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) label May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component:planning Route planning, decision-making, and navigation. (auto-assigned) run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci)

Projects

Status: To Triage

Development

Successfully merging this pull request may close these issues.

2 participants