|
| 1 | +# 1. C++20 baseline, linting/formatting tooling, and test strategy |
| 2 | + |
| 3 | +## Status |
| 4 | + |
| 5 | +Accepted |
| 6 | + |
| 7 | +## Context |
| 8 | + |
| 9 | +TickGuard is a header-only C++ library intended for embedded-adjacent targets |
| 10 | +(no dynamic threading frameworks, minimal heap use). It needs a consistent, |
| 11 | +low-friction toolchain so that contributors and CI reviewers judge code |
| 12 | +against the same bar, without requiring bespoke build-system integration for |
| 13 | +every tool. |
| 14 | + |
| 15 | +## Decision |
| 16 | + |
| 17 | +- **Language standard**: target C++20 exclusively (see `CMakeLists.txt`, |
| 18 | + `CXX_STANDARD 20`). Newer standards are not adopted until the project |
| 19 | + explicitly revisits this decision. |
| 20 | +- **Formatting**: `.clang-format` is Google-based but deliberately diverges |
| 21 | + from stock Google style — Allman braces, 4-space indent, 120-column limit, |
| 22 | + `ReflowComments: false`. Do not "fix" the codebase back to stock Google |
| 23 | + style; the divergences are intentional. |
| 24 | +- **Static analysis**: `.clang-tidy` enables the broad `*` ruleset with a |
| 25 | + short, explicitly-documented list of disabled checks and rationale for each |
| 26 | + (see the file's own header comments — e.g. `-llvm-header-guard` because the |
| 27 | + project uses `#pragma once` everywhere by design, not `#ifndef` guards). |
| 28 | + A small `WarningsAsErrors` allowlist (`modernize-use-nullptr`, |
| 29 | + `cppcoreguidelines-no-malloc`, etc.) is treated as a hard gate. Naming |
| 30 | + conventions (camelBack methods/variables, `m_`-prefixed CamelCase members) |
| 31 | + are enforced via `readability-identifier-naming` `CheckOptions` — see |
| 32 | + `AGENTS.md` for the human-readable version of the same rules. |
| 33 | +- **Linting is external to the build, by design**: `CMakeLists.txt` only sets |
| 34 | + `CMAKE_EXPORT_COMPILE_COMMANDS ON` to produce a `compile_commands.json`. |
| 35 | + There is intentionally no `add_custom_target` wrapping clang-tidy or |
| 36 | + clang-format into `cmake --build`. Lint/format checks run manually or in CI |
| 37 | + against the generated compile database, keeping the local build fast and |
| 38 | + tool-version-independent. |
| 39 | +- **Testing**: Catch2 v2.13.10, fetched automatically via `FetchContent` in |
| 40 | + `tests/CMakeLists.txt` (no manual install step), run through `ctest`. Tests |
| 41 | + inject time manually (`ev.tick(Xms)`) instead of sleeping wherever possible, |
| 42 | + reserving real `sleep_for`-based tests for the small surface that actually |
| 43 | + exercises the live worker thread (`EventSupervisorTests.cpp`). |
| 44 | + |
| 45 | +## Consequences |
| 46 | + |
| 47 | +- Contributors run clang-tidy/clang-format against `compile_commands.json` |
| 48 | + before submitting; neither is enforced automatically by `cmake --build`. |
| 49 | +- Enabling a new clang-tidy check or disabling an existing one requires |
| 50 | + updating the rationale comments at the top of `.clang-tidy` — undocumented |
| 51 | + suppressions should be treated as review blockers. |
| 52 | +- No parallel or competing lint/format configuration should be introduced; |
| 53 | + `.clang-tidy` and `.clang-format` are the single source of truth, and |
| 54 | + `AGENTS.md` restates their naming rules for quick human/agent reference |
| 55 | + rather than redefining them. |
| 56 | +- Bumping the language standard past C++20, or replacing Catch2, is a new |
| 57 | + decision and should get its own ADR rather than a silent change to |
| 58 | + `CMakeLists.txt`. |
0 commit comments