feat: Suppress SonarQube warnings for ZobristHash and PolyglotBook and improve coverage configuration
Build & Test (NowChessSystems) TeamCity build failed

This commit is contained in:
2026-04-17 22:40:19 +02:00
parent c9daec475c
commit 6fb78daacb
3 changed files with 19 additions and 8 deletions
+14
View File
@@ -22,6 +22,20 @@ sonar {
}.joinToString(",")
property("sonar.scala.coverage.reportPaths", scoverageReports)
property(
"sonar.issue.ignore.multicriteria",
"bot-zobrist-s2245,bot-polyglot-s2245"
)
property("sonar.issue.ignore.multicriteria.bot-zobrist-s2245.ruleKey", "scala:S2245")
property(
"sonar.issue.ignore.multicriteria.bot-zobrist-s2245.resourceKey",
"modules/bot/src/main/scala/de/nowchess/bot/util/ZobristHash.scala"
)
property("sonar.issue.ignore.multicriteria.bot-polyglot-s2245.ruleKey", "scala:S2245")
property(
"sonar.issue.ignore.multicriteria.bot-polyglot-s2245.resourceKey",
"modules/bot/src/main/scala/de/nowchess/bot/util/PolyglotBook.scala"
)
property(
"sonar.coverage.exclusions",
// UI renders JavaFX components; headless test environments cannot exercise rendering paths
@@ -69,11 +69,11 @@ final class PolyglotBook(path: String):
* - bits 12-14: promotion piece (0=none, 1=knight, 2=bishop, 3=rook, 4=queen)
*/
private def decodeMove(raw: Short, context: GameContext): Option[Move] =
val toFile = (raw & 0x07).toInt
val toRank = ((raw >> 3) & 0x07).toInt
val fromFile = ((raw >> 6) & 0x07).toInt
val fromRank = ((raw >> 9) & 0x07).toInt
val promotionBits = ((raw >> 12) & 0x07).toInt
val toFile = raw & 0x07
val toRank = (raw >> 3) & 0x07
val fromFile = (raw >> 6) & 0x07
val fromRank = (raw >> 9) & 0x07
val promotionBits = (raw >> 12) & 0x07
if toFile > 7 || toRank > 7 || fromFile > 7 || fromRank > 7 then None
else
@@ -120,7 +120,6 @@ final class PolyglotBook(path: String):
Move(from, to, MoveType.Normal())
/** Select a weighted random move from the list of book entries. */
@SuppressWarnings("scala:S2245")
private def weightedRandom(entries: Vector[BookEntry]): BookEntry =
if entries.length == 1 then entries.head
else
@@ -12,7 +12,6 @@ object ZobristHash:
private val pieceRands: Array[Long] = Array.ofDim(768)
// Side-to-move: XOR when Black to move
@SuppressWarnings("scala:S2245")
private val sideToMoveRand: Long = Random(0x1badb002L).nextLong()
// 4 entries: White kingside, White queenside, Black kingside, Black queenside
@@ -23,7 +22,6 @@ object ZobristHash:
// Initialize all random values using a seeded RNG for reproducibility
locally:
@SuppressWarnings("scala:S2245")
val rng = Random(0x1badb002L)
for i <- 0 until 768 do pieceRands(i) = rng.nextLong()
for i <- 0 until 4 do castlingRands(i) = rng.nextLong()