[CODE HEALTH] Fix clang-tidy bugprone-unused-local-non-trivial-variable warnings#4202
Merged
marcalff merged 2 commits intoJul 3, 2026
Merged
Conversation
7f1d70d to
c15e858
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses clang-tidy bugprone-unused-local-non-trivial-variable warnings across the SDK/tests/examples, reducing the clang-tidy warning ratchet thresholds accordingly as part of ongoing clang-tidy cleanup.
Changes:
- Remove dead/unused local variables in Prometheus exporter utils, OTLP examples, and OTLP file client tests.
- Ensure
Baggage::ToHeader()benchmark work isn’t optimized away by wrapping the call inbenchmark::DoNotOptimize(...). - Update the clang-tidy GitHub Actions warning limits (ratchet) and add a changelog entry.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
exporters/prometheus/src/exporter_utils.cc |
Removes unused local copies of instrument name/unit. |
api/test/baggage/baggage_benchmark.cc |
Prevents benchmarked ToHeader() work from being optimized away. |
examples/otlp/file_metric_main.cc |
Removes unused version/schema locals. |
examples/otlp/http_metric_main.cc |
Removes unused version/schema locals. |
examples/otlp/http_instrumented_main.cc |
Removes unused version/schema locals. |
exporters/otlp/test/otlp_file_client_test.cc |
Removes unused stringstream locals in rotation tests. |
CHANGELOG.md |
Adds an entry for this code health change (currently contains a placeholder link). |
.github/workflows/clang-tidy.yaml |
Lowers warning limits to reflect the removed warnings. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4202 +/- ##
==========================================
- Coverage 82.90% 82.88% -0.01%
==========================================
Files 405 405
Lines 17289 17287 -2
==========================================
- Hits 14331 14327 -4
- Misses 2958 2960 +2
🚀 New features to boost your workflow:
|
owent
approved these changes
Jul 1, 2026
…le warnings Resolve the 12 bugprone-unused-local-non-trivial-variable warnings from - prometheus exporter_utils.cc: drop two dead local copies (origin_name, unit); the descriptor fields are already used directly below. - baggage_benchmark.cc: wrap the two measured ToHeader() results in benchmark::DoNotOptimize so the calls are not optimized away and the locals are no longer flagged as unused. - otlp examples (file_metric / http_instrumented / http_metric main): drop unused version / schema locals. - otlp_file_client_test.cc: drop two unused output_stream locals in the file-rotation tests. Lower the clang-tidy warning limit 328 -> 316 (abiv1-preview) and 338 -> 326 (abiv2-preview). Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
c15e858 to
6fe1cf7
Compare
Contributor
Author
|
Dear reviewer |
marcalff
approved these changes
Jul 2, 2026
marcalff
left a comment
Member
There was a problem hiding this comment.
LGTM, thanks for the cleanup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves the
bugprone-unused-local-non-trivial-variablewarnings tracked in #4198 (part of #2053). 12 warnings across 6 files.exporters/prometheus/src/exporter_utils.cc: removed two dead local copies (origin_name,unit); the loop already usesinstrument_descriptor.name_/.unit_directly.api/test/baggage/baggage_benchmark.cc: the twoToHeader()results are the benchmarked work but were unused; wrapped them inbenchmark::DoNotOptimize(...)so the calls are not optimized away and the locals are no longer flagged.examples/otlp/{file_metric,http_instrumented,http_metric}_main.cc: removed unusedversion/schemalocals.exporters/otlp/test/otlp_file_client_test.cc: removed two unusedoutput_streamlocals in the file-rotation tests (the ostream test keeps its own).Ratchet lowered 328 -> 316 (abiv1-preview) and 338 -> 326 (abiv2-preview).
Verified locally: IWYU (all-options-abiv1-preview) clean, clang-format fixed point; the 12 warnings are the complete set for this check per the main clang-tidy CI report.
Fixes #4198