Skip to content

Adopt the STYLE_CPP.md additions from xff - #277

Merged
helly25 merged 1 commit into
mainfrom
style_cpp_sync
Aug 9, 2026
Merged

Adopt the STYLE_CPP.md additions from xff#277
helly25 merged 1 commit into
mainfrom
style_cpp_sync

Conversation

@helly25

@helly25 helly25 commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Docs only. Ports the clarifications that had accumulated in xff's STYLE_CPP.md, adapted to mbo's names and to what mbo actually has.

One is a reversal, and it matters

The doc said "a by-value std::string_view is never const". It now says the opposite: a by-value view follows ordinary const-correctness — const when never mutated, non-const exactly when resliced or reassigned. The reason is concrete: misc-const-correctness is enabled and flags a never-mutated view that is not const, so the old rule fought the linter. The corollary (iterate a mutable view and trim in place, rather than const + copy-to-mutate) and a worked example are included, along with the companion rule that a read-only string parameter is std::string_view by value, not const std::string&.

Also adopted

  • Trailing comma on every element of a registry-style table, so clang-format expands it uniformly.
  • A "value or error" type IS absl::StatusOr<T> — do not hand-roll value + status + ok-flag.
  • Matchers named unqualified via using ::testing::Foo;, never ::testing::Foo(...) inline.
  • mbo::testing::EqualsText for multi-line text, with a DropIndent raw-string golden (and the trailing-whitespace caveat, since the trim trailing whitespace hook would silently edit a golden).
  • ElementsAreArray({...,}) with a trailing comma for long matcher lists.
  • SizeIs / IsEmpty on the container, never a matched .size() / .empty().
  • bashtest's content matchers (expect_output_contains, expect_matches) with the whole-text anchoring caveat.

Fixed while here

The clang-tidy paragraph was stale: it still claimed "CI does not run it", which #270 changed. It now describes the dedicated clang-tidy CI job, the changed-files-on-a-branch vs whole-tree-on-main scoping, and that it is report-only until the sweep lands.

Deliberately not copied

xff's XFF_ macro prefix, xff/ paths and flag names, its C++23 baseline, its com_helly25_bashtest repo name (mbo uses the default helly25_bashtest), its no-shell-grep-in-bashtests pre-commit hook (mbo has no such hook, so claiming enforcement would be false), and its diff_golden.bzl — the golden-file guidance instead points at mbo's own //mbo/diff:diff.bzl.

xff's copy had grown several clarifications worth having here, adapted to
mbo's names and to what mbo actually has.

Notably one is a REVERSAL of the existing rule. The doc said "a by-value
std::string_view is never const"; it now follows ordinary
const-correctness - const when the view is never mutated, non-const
exactly when it is resliced or reassigned - because misc-const-correctness
(enabled) flags a never-mutated view that is not const. The corollary and
a worked example are included, plus the companion rule that a read-only
string parameter is std::string_view by value rather than
const std::string&.

Also adopted: trailing commas on every element of a registry-style table;
"a value or error type IS absl::StatusOr<T>"; matchers named unqualified
via `using`; mbo::testing::EqualsText with a DropIndent raw-string golden
for multi-line text; ElementsAreArray with a trailing comma for long
matcher lists; SizeIs/IsEmpty on the container instead of matching an
extracted .size()/.empty(); and bashtest's content matchers with the
whole-text anchoring caveat.

The clang-tidy paragraph was also stale - it still claimed CI does not run
clang-tidy, which #270 changed. It now describes the dedicated CI job,
the changed-files-on-a-branch vs whole-tree-on-main scoping, and that it
is report-only until the sweep lands.

Deliberately not copied: xff's XFF_ macro prefix, xff/ paths and flags,
its C++23 baseline, its com_helly25_bashtest repo name (mbo uses the
default), its no-shell-grep-in-bashtests hook (mbo has none), and its
diff_golden.bzl - the golden-file guidance instead points at mbo's own
//mbo/diff:diff.bzl.

Signed-off-by: helly25 <6420169+helly25@users.noreply.github.com>
@helly25
helly25 enabled auto-merge (squash) August 8, 2026 23:37
@helly25
helly25 requested a review from Fab-Cat August 8, 2026 23:37
@helly25
helly25 merged commit e0c8fde into main Aug 9, 2026
23 checks passed
@helly25
helly25 deleted the style_cpp_sync branch August 9, 2026 08:27
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