diff --git a/build.gradle.kts b/build.gradle.kts index 40e0af8..558165c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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 diff --git a/modules/bot/src/main/scala/de/nowchess/bot/util/PolyglotBook.scala b/modules/bot/src/main/scala/de/nowchess/bot/util/PolyglotBook.scala index d87db6c..a42c2af 100644 --- a/modules/bot/src/main/scala/de/nowchess/bot/util/PolyglotBook.scala +++ b/modules/bot/src/main/scala/de/nowchess/bot/util/PolyglotBook.scala @@ -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 diff --git a/modules/bot/src/main/scala/de/nowchess/bot/util/ZobristHash.scala b/modules/bot/src/main/scala/de/nowchess/bot/util/ZobristHash.scala index 39820f7..c0f2949 100644 --- a/modules/bot/src/main/scala/de/nowchess/bot/util/ZobristHash.scala +++ b/modules/bot/src/main/scala/de/nowchess/bot/util/ZobristHash.scala @@ -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()