Replies: 3 comments
-
Option C (clang-tidy) does not solve the version pinning problem — it makes things worseOption C's clang-tidy adoption exacerbates the core pain points raised in this discussion (version pinning, installation burden) rather than solving them. 1. Version pinning problem remains identical
2. Standalone installation is practically impossible
clang-format can be installed as a relatively lightweight standalone binary, but clang-tidy depends on the libclang runtime for AST parsing, resulting in a much larger installation footprint. 3. Compilation database is mandatoryclang-tidy cannot function properly without ConclusionWhile clang-tidy's static analysis value is acknowledged, it is a strictly heavier choice than clang-format for commit hook purposes across every dimension. If static analysis is desired, a clang-format + cppcheck combination under Option B (pre-commit framework) is more practical — cppcheck can be installed independently without LLVM dependencies and has much better cross-version stability. |
Beta Was this translation helpful? Give feedback.
-
Decision: Adopt Uncrustify (Option C)I ported the existing Test Results
Fully Compatible Settings
Known Limitations (accounting for the 2.6% diff)1. Function call argument continuation alignment clang-format uses a penalty-based system that dynamically decides alignment for function call arguments based on the open-paren position:
Uncrustify lacks this adaptive logic and must choose one strategy. We set // clang-format (paren-aligned for nested calls):
result = realloc(
prog->relations, new_cap * sizeof(info_t));
// uncrustify (flat indent):
result = realloc(
prog->relations, new_cap * sizeof(info_t));Both produce equally readable output. The flat indent is arguably more consistent. 2. Macro continuation body indent level may differ slightly. In the wirelog codebase, this affects only the ConclusionA 97.4% match rate is excellent for a cross-tool port. The remaining 2.6% stems from uncrustify's architectural limitation (no penalty-based line wrapping), with no practical impact on readability. We are adopting uncrustify as the linting gateway. Benefits:
|
Beta Was this translation helpful? Give feedback.
-
Resolution: Migrated to uncrustifyThis discussion evaluated clang-format 18 vs alternatives for the git commit hook. The project has since fully migrated to uncrustify (Option C from the original proposal): Current state (2026-04-10)
Original questions answered
Cleanup noteThe This discussion has served its purpose and can be closed. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Context
wirelog currently mandates clang-format 18 (
llvm@18) as the sole formatting/linting gate, enforced manually before each commit (seeCLAUDE.mdand.clang-format). As we consider adding a git pre-commit hook to automate this, it is worth evaluating whether clang-format 18 is the right tool for the job — or whether alternatives would make the hook simpler and more maintainable.Option A: Keep clang-format 18 as the linting gateway
Pros
.clang-formatconfig is mature and tested against representative files (lexer.c,program.c,wirelog.h).Cons
AlwaysBreakAfterReturnTypeis renamed in v19+). Contributors on rolling-release distros may have v19/v20, leading to spurious diffs.pip installornpm install. On some distros, getting exactly v18 means adding an LLVM apt repo or using Homebrew. This raises the barrier to first contribution.clang-formatmirror repo, which itself pins a version.AlwaysBreakAfterReturnType: All) are deprecated/renamed across versions, requiring maintenance when we eventually upgrade.Option B: Adopt the
pre-commitframework with clang-format as one hookUse pre-commit (
.pre-commit-config.yaml) to orchestrate multiple hooks, including clang-format.Pros
.pre-commit-config.yamlpins the exact clang-format version via its mirror repo; contributors just runpre-commit install.clang-tidy,cppcheck, trailing whitespace, SPDX license header check) without writing shell scripts.pre-commit run --all-filesworks identically in CI and locally.Cons
Option C: Replace clang-format with an alternative formatter/linter
Possible alternatives:
Pros of switching
Cons of switching
.clang-formatconfig represents significant tuning effort; recreating equivalent behavior in another tool is non-trivial.compile_commands.json) — Meson can generate this, but it adds a build step before linting.Questions for discussion
cppcheck --enable=warning)?brew install clang-format@18vspip install pre-commit && pre-commit install?)Looking forward to hearing everyone's thoughts.
Beta Was this translation helpful? Give feedback.
All reactions