Skip to content

Adopt a C++ style so the lint check can pass - #28

Merged
drzo merged 2 commits into
mainfrom
claude/loving-archimedes-r7fcwy
Nov 19, 2026
Merged

drzo merged 2 commits into
mainfrom
claude/loving-archimedes-r7fcwy

Conversation

@drzo

@drzo drzo commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

Follow-up to #27. The Lint Code Base workflow runs clang-format and cpplint, but the repository had no configuration for either, so both compared the code with defaults it never followed and failed on any pull request that touched a C++ file. This PR adds a style configuration and reformats the 21 C++ files changed by that merge. No linter is switched off.

Type of Change

  • Code refactoring
  • Build/CI configuration change

Related Issues

Related to #27

Changes Made

Style configuration

  • .clang-format: Google style (what cpplint verifies) with this code base's four-space indentation and a 120-column limit.
  • CPPLINT.cfg: the same line length; header guards named from the path under include/; three checks left out, each with its reason in the file:
    • build/c++11 rejects <mutex>, <thread>, <chrono> and <system_error> outright. The code is C++17 and uses them, so this check cannot be satisfied.
    • legal/copyright: there are no per-file copyright lines; the licence is in LICENSE.
    • runtime/references: non-const reference parameters. The Google style guide dropped this rule in 2020 and current cpplint no longer checks it.
  • test/CPPLINT.cfg: test sources may use using namespace.

The 21 files

  • Formatted with clang-format (about 1,850 changed lines, almost all whitespace and line wrapping).
  • Changes cpplint needed beyond formatting:
    • includes put in the standard order; test_comprehensive_e2e.cpp now includes project headers with quotes like the other tests;
    • header guards in bolt.hpp, bracket_matcher.hpp and network_metrics.hpp renamed to the derived names;
    • BandwidthTracker's single-argument constructor marked explicit;
    • <utility> included where std::move is used;
    • empty loop bodies written as {};
    • static_cast instead of function-style casts;
    • snprintf instead of strcpy in the GUI;
    • a few lines split to fit the limit, and two using namespace lines in demo programs marked NOLINT.
  • Two messages containing emoji are built from shorter pieces: the linter's clang-format measures emoji a column or two wider than other builds, so lines that only just fit were reported.
  • No behaviour changes are intended.

Testing

  • All existing tests pass
  • Manual testing performed

On commit 8044facf:

  • Lint Code Base passes, including clang-format, cpplint, the copy/paste detector and secret scanning.
  • All Windows jobs (MSVC and MinGW, Release and Debug), all Linux jobs (gcc and clang, Release and Debug; Ubuntu 22.04 and latest), ARM cross-compilation, Integration Tests (smoke test), E2E Tests, Code Coverage, AddressSanitizer, LeakSanitizer, Valgrind and CodeQL pass.
  • Locally on Linux (GCC): 98/98 CTest tests in Release and Debug; scripts/smoke_test.sh passes, including the GUI programs and model inference.

Reviewer Notes

  • Only these 21 files are formatted. The other 300 or so C++ files are untouched, so one of them will need clang-format -i (and possibly cpplint fixes) the first time a later PR changes it. Reformatting everything at once is possible but is a much larger diff; say if you want it.
  • The three cpplint checks left out are a style decision made here on the project's behalf. They are listed above so they can be reviewed.
  • The workflow linter still does not know the macos-15 runner labels. That does not affect this PR, which changes no workflow files, but it will fail the lint check on the next PR that touches e2e-ci.yml or release.yml.

🤖 Generated with Claude Code

https://claude.ai/code/session_011vmiZ7F3rQu7dith9sQw71

The Lint Code Base workflow runs clang-format and cpplint, but the
repository had no configuration for either, so both compared the code
with defaults it never followed and failed on any touched C++ file.

- .clang-format: Google style with this code base's four-space
  indentation and a 120-column limit.
- CPPLINT.cfg: the same line length, header guards named from the path
  under include/, and three checks left out with the reason for each:
  build/c++11 (it rejects <mutex>, <thread> and <chrono>, which this
  C++17 code uses), legal/copyright (the licence is in LICENSE) and
  runtime/references (dropped from the style guide in 2020).
- test/CPPLINT.cfg: test sources may use namespace using-directives.

The 21 C++ files changed by the previous merge are formatted with
clang-format. To satisfy cpplint they also get: includes in standard
order, header guards renamed to the derived names, an explicit
single-argument constructor, <utility> where std::move is used, empty
loop bodies written as {}, static_cast instead of function-style casts,
snprintf instead of strcpy, and a few lines split to fit the limit.
No behaviour changes.

The rest of the code base is not reformatted yet; a file will need
formatting when it is next changed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011vmiZ7F3rQu7dith9sQw71
The linter's clang-format build measures emoji a column or two wider
than other builds, so two lines that just fitted in 120 columns were
reported as needing a different wrap. Build those messages from shorter
pieces so every build formats them the same way.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011vmiZ7F3rQu7dith9sQw71
@drzo
drzo marked this pull request as ready for review November 19, 2026 02:13
Copilot AI balanced review requested due to automatic review settings November 19, 2026 02:13
@drzo
drzo merged commit 6886044 into main Nov 19, 2026
53 of 54 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Devin Review

Comment thread .clang-format
Comment on lines +11 to +13
# Four-space indentation; access specifiers sit one space in, as cpplint expects.
IndentWidth: 4
AccessModifierOffset: -3

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Formatter enforces the wrong indentation

IndentWidth enforces four-space indentation instead of the two spaces required by the Code Style Guidelines. Contributors cannot follow both the formatter and the documented rule.

Learn more

The repository's Code Style Guidelines require two-space indentation. The new formatter instead establishes four spaces as the repository-wide formatting policy, so running it preserves or creates violations of that requirement.

Example: Formatting a function body indents its statements by four spaces, while the contributor guideline requires two.

Recommended fix: Set IndentWidth to 2, adjust AccessModifierOffset to preserve the intended access-specifier placement, and reformat the affected files. If changing the repository policy is intended, explicitly reconcile the contributor guideline with that policy.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

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.

4 participants