Skip to content

Require braces and enforce clang-format in CI - #660

Merged
bsergean merged 3 commits into
masterfrom
style/require-braces-and-format-check
Nov 18, 2026
Merged

bsergean merged 3 commits into
masterfrom
style/require-braces-and-format-check

Conversation

@bsergean

Copy link
Copy Markdown
Collaborator

Require braces around if bodies, including single statements, and enforce the repository's formatting style in CI. .clang-format enables InsertBraces and disables short single-line if statements; the existing Allman brace style remains. Clang-format also applies brace insertion to else branches and loops.

The ClangFormat workflow follows the requested layout: macos-15, actions/checkout@v4, Homebrew clang-format, and a format check on PRs targeting master and pushes to master. make -f makefile.dev format and check_format share one script with per-file diffs and GitHub error annotations. It uses NUL-delimited tracked .cpp/.h paths, excluding vendored third_party code and untracked build artifacts.

Reformat existing maintained sources so the new check starts with a passing baseline. Preserve Windows header ordering through include categories and add explicit braces to the shared platform-specific stat error path that automatic insertion skips. Documentation covers the local commands and formatter override.

Validation:

  • clang-format 23.1.6 check passes; a deliberately unbraced if fails with the expected file annotation, and the format target inserts braces and repairs the failure.
  • Current master, including Add a configurable document root to the HTTP server #659, is merged and formatted.
  • Full OpenSSL and Network.framework suites: 33/33 passed each. The initial parallel suites collided on the existing chat test's fixed port; rerunning without that overlap passes the complete OpenSSL suite.
  • MinGW C++11 library and CLI build with warnings as errors.
  • Token comparison against master finds only whitespace, comments, braces and include-order changes in C++ sources. Vendored files are unchanged. git diff --check passes.

@bsergean
bsergean merged commit 639f9e8 into master Nov 18, 2026
14 checks passed
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.

1 participant