Skip to content

Add clang-format/clang-tidy tooling, lint Stop hook, and http_server_example#2

Open
stigsb wants to merge 4 commits into
mainfrom
feat/clang-tooling-and-http-example
Open

Add clang-format/clang-tidy tooling, lint Stop hook, and http_server_example#2
stigsb wants to merge 4 commits into
mainfrom
feat/clang-tooling-and-http-example

Conversation

@stigsb

@stigsb stigsb commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Summary

Adds the C++ lint toolchain and the remaining example from #1, plus a one-line bug fix surfaced while building it.

Reviewing commit-by-commit is recommended — the bulk reformat is isolated in its own commit.

Commits

  1. chore: adopt AGENTS.md with CLAUDE.md symlink — repo guidance lives in AGENTS.md; CLAUDE.md symlinks to it.
  2. build: clang-format / clang-tidy / pre-commit + lint Stop hook — see below.
  3. style: apply clang-format across the codebase — mechanical reformat only, no behavioural change.
  4. feat: http_server_example + cache_line.hpp <new> fix — the example (/metrics over cpp-httplib) and the bug that blocked all example builds on AppleClang.

Lint tooling

  • .clang-format matched to the existing style (clang-format 22).
  • .clang-tidy enables broad check families, with the checks the current code doesn't satisfy disabled so the tree is green today and WarningsAsErrors blocks regressions. Disabled checks are split into "design-driven, keep off" vs "candidates to fix-and-re-enable".
  • .pre-commit-config.yaml: clang-format via the pinned mirror; clang-tidy via scripts/run-clang-tidy-precommit.sh, which lints only TUs the compile DB knows and skips gracefully when unconfigured.
  • .claude/hooks/lint-check.sh (+ .claude/settings.json): a Stop hook that blocks a turn from finishing until files changed vs HEAD are clang-format- and clang-tidy-clean. Both wrappers add the macOS SDK -isysroot so clang-tidy can read an AppleClang compile database.

Verification

  • ctest: 122/122 pass.
  • Both example targets build; /metrics example links.
  • clang-tidy green across all TUs in the compile DB; clang-format clean tree-wide.

Addresses the examples/http_server_example.cpp, .clang-format, and .clang-tidy items in #1.

Notes for the reviewer

  • clang-tidy intentionally does not cover bench/* (Google Benchmark isn't in the default compile DB); clang-format still does.
  • The clang-tidy "currently-failing" disables (e.g. modernize-use-nodiscard, modernize-use-ranges, readability-redundant-*) are real modernizations you may want to apply to the code and re-enable, rather than keep off.

stigsb added 4 commits June 29, 2026 15:52
Move the repo guidance into AGENTS.md (read by agent tooling generally) and
point CLAUDE.md at it via symlink so both resolve to the same content.
- .clang-format: style matched to the codebase (clang-format 22).
- .clang-tidy: broad bugprone/performance/modernize/readability/portability/
  clang-analyzer families, with the checks the existing code does not yet
  satisfy disabled so the tree is green today; WarningsAsErrors keeps new
  violations from sneaking in. Design-driven disables (#pragma once, terse
  hot-path names, label macros) are grouped separately from the candidates
  to fix-and-re-enable later.
- .pre-commit-config.yaml: clang-format via the pinned mirror; clang-tidy via
  scripts/run-clang-tidy-precommit.sh, which lints only translation units the
  compile DB knows about and skips gracefully when no build dir exists.
- .claude/hooks/lint-check.sh + settings.json: a Stop hook that blocks turn
  completion until files changed vs HEAD are clang-format clean and clang-tidy
  clean. Both wrappers add the macOS SDK isysroot so clang-tidy can read an
  AppleClang compile database.
Mechanical reformat to the new .clang-format. No behavioural changes.
label_def.hpp gains clang-format on/off guards around the preprocessor
metaprogramming, whose hand-alignment clang-format would otherwise mangle.
examples/http_server_example.cpp exposes a Prometheus /metrics endpoint over
cpp-httplib (closes the remaining example item in #1). Building it surfaced a
pre-existing bug: detail/cache_line.hpp used
std::hardware_destructive_interference_size without including <new>, which
broke every example build on AppleClang; add the include.
@codecov-commenter

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

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