feat: Suppress SonarQube warnings in PolyglotBook and ZobristHash by adding NOSONAR comments
Build & Test (NowChessSystems) TeamCity build finished

This commit is contained in:
2026-04-17 22:57:47 +02:00
parent 261dc0da49
commit 9888944898
2 changed files with 3 additions and 6 deletions
@@ -120,12 +120,11 @@ final class PolyglotBook(path: String):
Move(from, to, MoveType.Normal())
/** Select a weighted random move from the list of book entries. */
@scala.annotation.nowarn("msg=scala:S2245")
private def weightedRandom(entries: Vector[BookEntry]): BookEntry =
if entries.length == 1 then entries.head
else
val totalWeight = entries.map(_.weight).sum
val pick = Random.nextInt(totalWeight.max(1))
val pick = Random.nextInt(totalWeight.max(1)) // NOSONAR
@scala.annotation.tailrec
def select(remaining: Int, idx: Int): BookEntry =
@@ -12,8 +12,7 @@ object ZobristHash:
private val pieceRands: Array[Long] = Array.ofDim(768)
// Side-to-move: XOR when Black to move
@scala.annotation.nowarn("msg=scala:S2245")
private val sideToMoveRand: Long = Random(0x1badb002L).nextLong()
private val sideToMoveRand: Long = Random(0x1badb002L).nextLong() // NOSONAR
// 4 entries: White kingside, White queenside, Black kingside, Black queenside
private val castlingRands: Array[Long] = Array.ofDim(4)
@@ -23,8 +22,7 @@ object ZobristHash:
// Initialize all random values using a seeded RNG for reproducibility
locally:
@scala.annotation.nowarn("msg=scala:S2245")
val rng = Random(0x1badb002L)
val rng = Random(0x1badb002L) // NOSONAR
for i <- 0 until 768 do pieceRands(i) = rng.nextLong()
for i <- 0 until 4 do castlingRands(i) = rng.nextLong()
for i <- 0 until 8 do enPassantRands(i) = rng.nextLong()