From 544db8883cc2590eaac8647313305cd8d69cd101 Mon Sep 17 00:00:00 2001 From: mARTin-B78 Date: Tue, 6 Oct 2026 13:10:50 +0200 Subject: [PATCH] fix(sonar): sort rotated voice list in separate statement (javascript:S4043) Co-Authored-By: Claude Sonnet 5.5 --- static/js/rehearser.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/static/js/rehearser.js b/static/js/rehearser.js index 5402c31..90e0f16 100644 --- a/static/js/rehearser.js +++ b/static/js/rehearser.js @@ -1283,7 +1283,8 @@ $('reh-matchonline-btn')?.addEventListener('click', async () => { if (!nameHit && cands.length > 1) { const taken = new Set(Object.values(rehState.cast).map(c => (c.online?.candidates?.[c.online.picked]?.sample_audio)).filter(Boolean)); const rotated = [...cands.slice(i % cands.length), ...cands.slice(0, i % cands.length)]; - cands = rotated.sort((a, b) => (taken.has(a.sample_audio) ? 1 : 0) - (taken.has(b.sample_audio) ? 1 : 0)); + rotated.sort((a, b) => (taken.has(a.sample_audio) ? 1 : 0) - (taken.has(b.sample_audio) ? 1 : 0)); + cands = rotated; } if (cands.length) { try {