Repository navigation
chore(test-infra): lint bare boolean operators inside drogon CHECK/REQUIRE - #77
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Independent review round — 3-perspective verification (completeness / correctness / impact)Cross-verified the PR claims against the commit ( PR claims — verified TRUE ✅
New findings this round: Warnings (SHOULD FIX)W1. W2. C++14 digit separators swallow code as a char literal (verified false negative) W3. Empty scan silently passes — the gate degrades to a no-op if the target dir vanishes Suggestions (CONSIDER)
Summary of changes
|
Fixes #76. drogon's CHECK/REQUIRE expand their argument via (Decomposer() <= expr); an unparenthesized boolean chain re-associates to (Decomposer() <= a) || b and silently mis-evaluates (bit PR #68 as a seemingly-flaky assertion). New static check tools/test/scripts/drogon_macro_bool_check.py (with --selftest) flags top-level bare operators; wired into CI static checks next to the naming validator. Convention documented in docs/backend/testing-guide.md §2 with the safe forms ((bool)(...), outer parens, split assertions) and the repo's existing FunctionalTest.cc precedent. Current tree scans clean (109 files).
36872e8 to
4381ef3
Compare
Fixes #76 (registered from the PR #68 review round).
Why
drogon's
CHECK/REQUIREare macros, not functions:CHECK_INTERNAL__expands the argument via(internal::Decomposer() <= expr), and macro substitution does not parenthesize — a barea || bre-associates to(Decomposer() <= a) || band silently mis-evaluates, presenting as a flaky assertion. Real instance while debugging PR #68:CHECK(body.isMember("error") || body.isMember("code"))failed although the logged raw body contained the key.What
tools/test/scripts/drogon_macro_bool_check.py— flags top-level bare||/&&inCHECK(...)/REQUIRE(...)arguments; safe forms ((bool)(...), outer parens, operators nested in call/sub-expression brackets,*_THROWSvariants, string/comment contents) are recognized. Ships with--selftest(14 embedded cases, mirroring the spec-governance tool's pattern).--selftest+ scan oftests/).docs/backend/testing-guide.md§2 gains a [MUST] subsection with the rule, the safe/forbidden forms, and the existingFunctionalTest.ccprecedent.Current
tests/tree scans clean (109 files) — the lint is purely preventive.Verification
--selftestOK (14/14), fulltests/scan OK locally.