Skip to content

Clean up clang-tidy 21 findings; move lint to ubuntu-26.04 - #238

Open
aaylward wants to merge 1 commit into
mainfrom
claude/clever-brown-yvg88z
Open

aaylward wants to merge 1 commit into
mainfrom
claude/clever-brown-yvg88z

Conversation

@aaylward

@aaylward aaylward commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

What

Follow-up to #237, which kept lint on ubuntu-24.04. The clang-tidy on 26.04 runs checks the old one didn't, and they flagged about 180 sites. This PR fixes those sites instead of turning the checks off, then moves lint to 26.04.

  • modernize-use-scoped-lock: std::lock_guard<std::mutex> → std::scoped_lock, which covers most of the diff
  • modernize-use-designated-initializers, -use-ranges, -use-starts-ends-with
  • readability-container-contains, -math-missing-parentheses, -use-concise-preprocessor-directives
  • Headers::Remove → std::erase_if. The auto-fix produced erase(ranges::remove_if(...), end()), which doesn't compile, so this one was done by hand.
  • beast_transport.cc:
    • WriteWire takes const std::shared_ptr&; the lambda already copied it.
    • the TLS context is read once, right after the has_value() check (bugprone-unchecked-optional-access).
    • message::contains, which Boost 1.90 has.
  • runtime/src/http/.clang-tidy also excludes clang-analyzer-optin.cplusplus.VirtualCall. It's a false positive inside Boost.Asio's resolver_thread_pool destructor, reached only from beast_transport.cc, and it sits next to the existing Boost NewDelete exclusion.
  • metrics.cc aliases the pointer-to-member type so clang-format 18 and 21+ format that line the same way.

Not changed: clang-tidy 22 adds bugprone-exception-escape and -unchecked-string-to-number-conversion hits, mostly atoi in the example main() functions. The 26.04 runner's clang-tidy doesn't report them, so they're out of scope here.

Testing

  • clang-tidy 21.1.6 over the lint job's file set: clean, except beast_transport.cc:158 locally. This machine has Boost 1.83 without fields::contains; the CI runner's Boost and Bazel's Boost 1.90 have it.
  • clang-format 18.1.3, 21.1.8 and 22.1.8 --dry-run --Werror: clean
  • bazel test //... --config=ci: 130/130 pass with both clang and gcc, under -Werror
  • CI: all 16 checks green, including lint on ubuntu-26.04

Checklist

  • Tests added/updated for the change (N/A: behavior-preserving refactors; existing suites cover the touched code, including Headers::Remove)
  • bazel test //... passes locally
  • Formatting clean (clang-format, clang-tidy)
  • Architectural decisions recorded as an ADR (N/A)

ubuntu-26.04's clang-tidy enables checks the 24.04 build never ran.
Fix the sites instead of disabling them:

- modernize-use-scoped-lock: std::lock_guard<std::mutex> -> std::scoped_lock
- modernize-use-designated-initializers
- modernize-use-ranges, -use-starts-ends-with
- readability-container-contains, -math-missing-parentheses,
  -use-concise-preprocessor-directives
- Headers::Remove uses std::erase_if
- beast_transport: const& shared_ptr param; deref ssl once after the
  has_value() check (bugprone-unchecked-optional-access)

runtime/src/http/.clang-tidy additionally excludes
clang-analyzer-optin.cplusplus.VirtualCall, a false positive inside
Boost.Asio's resolver_thread_pool reached only from beast_transport.cc.

metrics.cc aliases the pointer-to-member type so clang-format 18 and
21+ agree on the lambda signature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants