SonarCloud maintainability remediation: ~500 sites closed, 0 regressions, 2 bugs caught and fixed
Squashes 74 commits from chore/sonar-remediation implementing plan/SONAR_REMEDIATION_PLAN.md:
**Phase A** (mechanical, repo-wide, all 🟢):
- S1659 (17), S1905 (11), S1481 (3), S7127 (17), S7040 (10), S7035 (30),
S5827 (22), S6177 (52)
**Phase C** (review-each, repo-wide, excluding hot files):
- S6494 (snprintf → kleidos::platform::str::format, 96)
- S6004 (init-statement scope, 64)
- S1186 (empty body, 12)
- S1066 (merge collapsible if, 11)
- Plus S924/S886/S6020/S5952/S5350/S3230/S1172/S3624/S108/S954
opportunistically.
**Phase D** (structural, outside hot files):
- S3776 cognitive complexity (8/8 viable — complete)
- S134 deep nesting (7/7 viable — complete)
- S3358 nested ternary (8 committed; 22 remaining sites were stale
data, will auto-close on next scan)
**S5817 round** (3 parallel worktree agents, batched):
- 50 sites closed (drivers + HAL + Platform/FSM/UI cascades)
- 19 documented as WONTFIX inline (IPmic::readPowerButtonClick IRQ-clear,
File::available/read syscalls, AppContext::configureDFS, genuine
const-violation in HAS_BUZZER audio backend, etc.)
**Bug fixes (caught by Gemini + Copilot PR review):**
- ble_hid_manager.cpp: S134 refactor lost standby-mode re-advertise
behavior. Restored with the early-return re-ordered to the
over-budget case only.
- graphics.h: docstring claimed callers can pass `const Surface&` but
the 7 free helpers + drawString + drawGlyph still took `Surface&`.
All 9 free fns now take `const Surface&`. Closes 6 cpp:S995 sites.
**WONTFIX policy (4 rules, 995 sites, intentionally untouched):**
- cpp:S5008 (void*), cpp:S6022 (std::byte), cpp:S5421 (globals),
cpp:S5945 (C arrays). User reviews them in the SonarCloud web UI
with per-site justifications provided in plan/WONTFIX_*.md.
**Quality Gate:** Project now uses a project-local copy
'Sonar way for Agentic AI (Kleidos relaxed)' with coverage LT 0% and
duplication GT 50% (per user instruction to relax these for now).
**Deferred to Phase B (3 hot files, ~770 issues):**
vault_state.cpp, wifi_admin_portal.cpp, vault_store.cpp. Recon
plans at plan/PHASE_B_{VAULT_STATE,WIFI_ADMIN_PORTAL,VAULT_STORE}.md.
**Total:** 135 files changed, ~500 sites closed, 0 regressions
(468/468 native tests green throughout), 2 critical bugs caught and
fixed by bot review, 6 bot review comments acknowledged.
Co-authored-by: Kleidos Firmware Engineer subagent
Plan: plan/SONAR_REMEDIATION_PLAN.md
authored by