feat: add code quality toolchain
Three Pillars
1. Static Analysis (clang-tidy + compiler warnings)
| Layer | Trigger | Config |
|---|---|---|
| Editor (real-time) | clangd auto | .clangd |
| CLI (per-file) | clang-tidy file.cpp |
.clang-tidy |
| Build (all TUs) | CEPCSW_STRICT=ON |
CMakeLists.txt → CMAKE_CXX_CLANG_TIDY
|
| CI (full build + test) |
build:strict job (manual) |
.gitlab-ci.yml |
Compiler baseline: -Wall -Wextra -Wpedantic -Wshadow. Strict mode adds -Werror.
2. Formatting (clang-format)
| Layer | Trigger | Policy |
|---|---|---|
| Editor (save) | clangd auto | .clang-format |
| CLI | clang-format -i --style=file |
.clang-format |
| Pre-commit |
source setup.sh (auto) |
new files → strict reject; old files → auto-format |
| CI |
format-check job (automatic) |
new files in MR → strict check; old files → skip |
3. Dynamic Analysis (ASan + UBSan)
| Layer | Trigger |
|---|---|
| Local build | CEPCSW_STRICT=ON ./build.sh |
| CI |
build:strict job (manual) — build + test with sanitizers |
Quick Start
# Daily build
source setup.sh && ./build.sh
# LSP (editor)
CEPCSW_BEAR=ON ./build.sh # → compile_commands.json
# Strict mode (all three pillars)
CEPCSW_STRICT=ON ./build.sh # -Werror + clang-tidy + ASan + UBSan
Old Code Compatibility
Cutoff date: 2026-05-01 (CEPCSW_STRICT_CUTOFF). Files last modified before this date are exempt from strict checks. Pre-commit auto-formats old files; CI skips them.
Design Principles
-
One switch:
CEPCSW_STRICT=ONenables all three pillars - Zero pip/npm: all tooling from CVMFS
- Pure bash: no external dependencies for hooks
- Incremental: old code exempt, new code strict
Files (16)
.clang-format .clang-tidy .clangd .vscode/ .dir-locals.el CMakeLists.txt cmake/CEPCSWOptions.cmake cmake/CEPCSWStrictWarnings.cmake build.sh setup.sh scripts/git-hooks/pre-commit .gitlab-ci.yml AGENTS.md doc/editors-setup.md
Edited by Li Zhihao