From f2ecbd055c66ab8e1468aba1039c4c60276a0786 Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Sun, 8 Nov 2026 04:22:13 +0100 Subject: [PATCH] fix: keep the resistive-lock test's controller table index in range for CI Sonar (S3519) doesn't see the REQUIRE ending the test, so it read the table at the index below the first resistance-free position as possibly -1. --- tests/unit/test_cntrl.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/unit/test_cntrl.cpp b/tests/unit/test_cntrl.cpp index 43c983edd..e6c53940c 100644 --- a/tests/unit/test_cntrl.cpp +++ b/tests/unit/test_cntrl.cpp @@ -67,6 +67,9 @@ TEST_CASE("cntrl: ScndCtrlResistiveLock keeps the field shunting off at zero and REQUIRE(locked->ScndCtrlPosNo > 0); auto const resistancefree{resistance_free_position(locked.mover())}; REQUIRE(resistancefree > 1); + if (resistancefree <= 1) { + continue; // not reached, the REQUIRE above ends the test; tells the static analysis the index below is in range + } REQUIRE(locked->RList[resistancefree - 1].R >= 0.01); SUBCASE("zero") {