ci: add static analysis, sanitizers, and formatting enforcement #24
Reference in New Issue
Block a user
Delete Branch "ci/tier1-review-automation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Add Tier 1 review automation to catch issues before human review. This reduces the review burden by automating the mechanical checks that were previously caught in multi-round post-review fix cycles.
Changes
CI Pipeline (.gitea/workflows/ci.yaml)
Expanded from 1 job to 3 parallel jobs:
Build System (CMakeLists.txt)
Code Quality
Verification
Impact
Every PR now automatically gates on format, static analysis, strict warnings, and memory/thread safety — reducing human review rounds from 3-4 to 0-1 for mechanical issues.
Architect Review: PR #24 — "ci: add static analysis, sanitizers, and formatting enforcement"
Verdict: PASS — No critical issues found.
Summary
Warnings (non-blocking)
W1: Sanitizers job skips integration tests
.gitea/workflows/ci.yaml:57The
sanitizersjob only runs unit tests, not integration tests. This leaves a gap in sanitizer coverage for server-side code paths. Consider adding a note to track this, or a follow-up to run a subset of integration tests under ASan.W2: TSan removed (Docker incompatible)
.gitea/workflows/ci.yaml:43-45The sanitizer matrix is
[address]only. TSan was removed due to Docker incompatibility. This is documented and reasonable, but TSan should be tracked as a follow-up — the multithreaded pipeline is exactly the kind of code that benefits from TSan. Suggest opening an issue to revisit TSan when Docker supportsthreadsanitizer (or running TSan outside Docker).W3: Duplicate
-gin CMakeLists.txtCMakeLists.txt:16-19The sanitizer flags include
-gredundantly — it is already in the base compile options on line 9 (add_compile_options(-Wall -g -O3)). Harmless but noisy. Fix: Remove-gfrom the sanitizeradd_compile_options.W4: Duplicate typedef in protocol.h
src/shared/protocol.h:8,23While C11 permits compatible duplicate typedefs, this is a code smell likely introduced by the formatting pass. Remove the second one on line 23.
Style Notes (informational)
S1:
file(GLOB)anti-patternCMakeLists.txt:41-44Pre-existing. CMake documentation recommends against
file(GLOB)for source collection. Worth noting for a future cleanup — switching to explicit source lists.S2:
compression_levelparameter unusedsrc/shared/compression.c:10The
compression_levelparameter is accepted but never used (hardcodes zstd default). The(void)compression_level;cast silences the warning but hides the semantic gap. Consider using the parameter or documenting it is unused.S3:
off_tcast direction unusualsrc/shared/file.c:264The cast from
off_t(signed) tounsigned long longis safe here but the more conventional approach is comparing in the same signed domain. Works correctly, just noting the pattern.S4: Scanner leak fix is correct (positive finding)
src/client/scanner.c:161The new
array_list_delete(chunk_data);whenchunk_data->size == 0is a genuine bug fix. Previouslychunk_datawas leaked on every call when no files matched criteria. Verified thatarray_list_deletehandlessize == 0correctly.S5: Pre-existing null check missing
src/shared/metadata.c:35-36No null check after
malloc. Pre-existing but the const-correctness changes touched this file. Consider adding a null check in a follow-up.S6: Missed const opportunities
src/shared/protocol.h:25,src/shared/transport_tcp.h:30send_strtakeschar* databut should takeconst char* data. Similarlyclient_connecttakeschar* hostbut should beconst char* host. The const-correctness pass missed these.Positive Findings
.clang-formatconfig matches existing code style; formatting changes are consistent and safeRecommendation
Merge. The PR is well-structured, warning fixes are correct, const-correctness improvements are safe, the scanner leak fix is a genuine bugfix, and the CI infrastructure is solid. The warnings above are minor and can be addressed in follow-ups. The duplicate typedef (W4) is the only thing worth fixing before merge if trivial — it is a one-line deletion.