Skip to content

format: indent continuations by 4, and two style conventions - #125

Merged
jll63 merged 5 commits into
boostorg:developfrom
jll63:fix/format
Sep 23, 2026
Merged

jll63 merged 5 commits into
boostorg:developfrom
jll63:fix/format

Conversation

@jll63

@jll63 jll63 commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

(Written by Claude Code, on behalf of @jll63.)

The repo-wide reformat that was deferred until the open PRs cleared, plus the
hand changes it turned up. Five commits, the mechanical one first so the rest
read clean on top of it.

format: the config, and the churn

.clang-format said AlignAfterOpenBracket: AlwaysBreak, which is a misnomer:
it keeps a continuation aligned under the open paren, and clang-format 22
maps it to true, which is alignment. The house style is an indent of 4
everywhere, so this is false plus the four BreakAfterOpenBracket* options
that keep an if/while/switch condition off the paren column, and the
braced-list pair that restores the break after { that AlwaysBreak used to
provide. No PenaltyBreak* value and no BlockIndent gets there; both were
probed.

Macros: teaches clang-format to expand the method macros to ID PARAMETERS.
Without it the parameter list is parsed as an expression, where & is a
binary operator, and the first parameter comes out as Cat & a1 — 49 sites
fixed:

-BOOST_OPENMETHOD_OVERRIDE(meet, (Cat & a1, Cat& a2, std::ostream& os), void) {
+BOOST_OPENMETHOD_OVERRIDE(meet, (Cat& a1, Cat& a2, std::ostream& os), void) {

The expansion omits the return type deliberately: with one in it, clang-format
breaks after the return type and indents the method name by 8.
BOOST_OPENMETHOD_OVERRIDER is left out because it appears in expression
position (...)::fn(args)), where the expansion never applies and only wrecks
the wrapping of the sites that do match.

dev/reformat is pinned to clang-format-22 — 18 and 19 reject
BreakAfterOpenBracketFunction as an unknown key and refuse to run at all —
and now takes its file list from git ls-files, having globbed a stale
examples/ directory that has not existed for some time, which left ce/
unformatted.

core: two predicates hoisted

Both were indented off the 4-column grid. clang-format measures a continuation
from the column of the enclosing bracket's content, so the (( of the
classes_agree_with fold put its operands at 13, 14 and 17, and the ( in
same_reference_category put its second operand at 38. No option moves any of
them — AlignAfterOpenBracket and AlignOperands were probed in every
combination — but removing a level of nesting does. After this, every line in
the branch sits on a multiple of 4.

class_agrees_with carries the diagnostic one class at a time, which is a real
improvement: the compiler now names the offending class and the two registries
in conflict, where the folded form could only report that a requirement failed
for the pack as a whole.

style: two conventions

  • A function body that names detail:: more than once opens with
    using namespace detail; and drops the qualification — 35 bodies. A single
    use does not earn one: every single-use body was tried and reformatted to
    check, and none came out shorter.
  • A blank line before a return, except where the return opens its block.

doc: CLAUDE.md

Records both conventions, corrects the Formatting section (which still
advertised AlwaysBreak), and writes down the three shapes clang-format cannot
be configured into, so they do not get re-litigated: the ternary break, the
::fn argument spacing, and the clang-format off files under
doc/modules/ROOT/examples/.

Checks

  • clang 22, Debug, Linux: 202/202.
  • MSVC v18 x64, Debug, Ninja: 197/197, no warnings under /W4 /WX. Run
    locally, not left to CI, since the 24 compile-fail tests and the export
    spellings are the platform-divergent part. The 197 vs 202 is the
    dynamic_loading group, which the Windows configure does not register.

Reviewing with git show -w makes the first commit nearly empty, which is the
point: everything of substance is in the four that follow.

🤖 Generated with Claude Code

jll63 and others added 5 commits September 22, 2026 16:48
`.clang-format` said `AlignAfterOpenBracket: AlwaysBreak`, a misnomer: it keeps
a continuation aligned under the open paren, and clang-format 22 maps it to
`true`, which is alignment. The house style is an indent of 4 everywhere, so
this is `false` plus the four `BreakAfterOpenBracket*` options that keep an
`if`/`while`/`switch` condition off the paren column, and the braced-list pair
that restores the break after `{` that `AlwaysBreak` used to provide.

`Macros:` teaches clang-format to expand the method macros to `ID PARAMETERS`.
Without it a parameter list is parsed as an expression, where `&` is a binary
operator, and the first parameter comes out as `Cat & a1` - 49 sites. The
expansion omits the return type on purpose: with one in it, clang-format breaks
after the return type and indents the method name by 8.
`BOOST_OPENMETHOD_OVERRIDER` is left out because it appears in expression
position, where the expansion never applies and only wrecks the wrapping.

`dev/reformat` is pinned to `clang-format-22` - 18 and 19 reject
`BreakAfterOpenBracketFunction` as an unknown key and refuse to run at all -
and takes its file list from `git ls-files`, having globbed a stale `examples/`
directory that has not existed for some time, which left `ce/` unformatted.

The rest is the output of `dev/reformat`, no hand edits.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Both were indented off the 4-column grid, because clang-format measures a
continuation from the column of the enclosing bracket's content: the `((` of
the `classes_agree_with` fold put its operands at 13, 14 and 17, and the `(` in
`same_reference_category` put its second operand at 38. No clang-format option
moves any of them; removing a level of nesting does.

`class_agrees_with` now carries the diagnostic, one class at a time, so the
compiler names the class and the two registries in conflict instead of
reporting that a requirement failed for the pack as a whole.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A function body that names `detail::` more than once now opens with
`using namespace detail;` and drops the qualification, with a blank line after
the run of `using` declarations. The directive covers the body only, so
signatures keep their qualification. 35 bodies across 11 files.

A single use does not earn a directive: the `using` line costs a line, so it
only pays where it unwraps two. Every single-use body was tried and reformatted
to check; none came out shorter.

`using detail::generic_compiler;` in test_slot_allocator.cpp is dropped rather
than requalified - the qualification there *is* the declaration, and the
directive already brings the name in.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Except where the return opens its block - the whole body of a function or
lambda, the body of an `if`, a `case` - which would put the blank line
immediately after the `{`. Where a comment is attached to the return, the blank
line goes above the comment rather than between them.

clang-format has no option for this, so `dev/reformat` neither adds nor removes
these lines; it is maintained by hand.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The Formatting section still advertised `AlignAfterOpenBracket: AlwaysBreak`.
It now covers the clang-format 22 pin, the `Macros:` entries and why
`BOOST_OPENMETHOD_OVERRIDER` is excluded, the multiple-of-4 rule with the
reason continuations go off the grid, the blank line before a return, and the
three shapes clang-format cannot be configured into - so the ternary, the
`::fn` argument spacing and the `clang-format off` files do not get
re-litigated.

The new section records the `using namespace detail` rule and the two traps a
mechanical strip falls into: a using-declaration, where the qualification is
the declaration, and `BOOST_OPENMETHOD_UNLESS_MRDOCS(detail::)`, which is not a
qualification at all.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@cppalliance-bot

Copy link
Copy Markdown

An automated preview of the documentation is available at https://125.openmethod.prtest3.cppalliance.org/libs/openmethod/doc/html/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-09-22 21:28:37 UTC

@codecov

codecov Bot commented Sep 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.25000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.34%. Comparing base (159f10f) to head (f093df7).
⚠️ Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
include/boost/openmethod/core.hpp 87.50% 0 Missing and 1 partial ⚠️
...e/boost/openmethod/policies/minimal_cover_hash.hpp 80.00% 0 Missing and 1 partial ⚠️
...boost/openmethod/policies/minimal_perfect_hash.hpp 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #125      +/-   ##
===========================================
+ Coverage    92.30%   92.34%   +0.04%     
===========================================
  Files           27       27              
  Lines         2222     2234      +12     
  Branches       679      679              
===========================================
+ Hits          2051     2063      +12     
  Misses         112      112              
  Partials        59       59              
Files with missing lines Coverage Δ
include/boost/openmethod/detail/ostdstream.hpp 96.77% <100.00%> (ø)
include/boost/openmethod/detail/static_list.hpp 100.00% <ø> (ø)
include/boost/openmethod/initialize.hpp 92.97% <100.00%> (+<0.01%) ⬆️
include/boost/openmethod/inplace_vptr.hpp 100.00% <100.00%> (ø)
include/boost/openmethod/interop/boost_any.hpp 100.00% <100.00%> (ø)
...de/boost/openmethod/interop/boost_type_erasure.hpp 100.00% <100.00%> (ø)
include/boost/openmethod/interop/std_any.hpp 100.00% <100.00%> (ø)
...nclude/boost/openmethod/interop/std_unique_ptr.hpp 90.00% <ø> (ø)
include/boost/openmethod/interop/std_weak_ptr.hpp 98.85% <100.00%> (ø)
include/boost/openmethod/interop/virtual_any.hpp 100.00% <100.00%> (ø)
... and 10 more

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a0fc899...f093df7. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jll63
jll63 merged commit 108fd89 into boostorg:develop Sep 23, 2026
56 checks passed
@jll63
jll63 deleted the fix/format branch September 23, 2026 03:04
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