From d0da50418a7afa283b693cc4b2a6aed221040f96 Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Thu, 17 Aug 2023 00:26:16 -0700 Subject: [PATCH] Fix warning Classes that contain only a companion object should be replaced with a named object declaration (#28710) --- .../src/chip/onboardingpayload/Verhoeff.kt | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/src/controller/java/src/chip/onboardingpayload/Verhoeff.kt b/src/controller/java/src/chip/onboardingpayload/Verhoeff.kt index 524c74b6462380..52974e7d32df67 100644 --- a/src/controller/java/src/chip/onboardingpayload/Verhoeff.kt +++ b/src/controller/java/src/chip/onboardingpayload/Verhoeff.kt @@ -17,29 +17,27 @@ package chip.onboardingpayload -class Verhoeff { - companion object { - fun dihedralMultiply(x: Int, y: Int, n: Int): Int { - val n2 = n * 2 - var newX = x % n2 - var newY = y % n2 - if (newX < n) { - if (newY < n) return (newX + newY) % n - return ((newX + (newY - n)) % n) + n - } - if (newY < n) return ((n + (newX - n) - newY) % n) + n - return (n + (newX - n) - (newY - n)) % n +object Verhoeff { + fun dihedralMultiply(x: Int, y: Int, n: Int): Int { + val n2 = n * 2 + var newX = x % n2 + var newY = y % n2 + if (newX < n) { + if (newY < n) return (newX + newY) % n + return ((newX + (newY - n)) % n) + n } + if (newY < n) return ((n + (newX - n) - newY) % n) + n + return (n + (newX - n) - (newY - n)) % n + } - fun dihedralInvert(value: Int, n: Int): Int { - if (value > 0 && value < n) return n - value - return value - } + fun dihedralInvert(value: Int, n: Int): Int { + if (value > 0 && value < n) return n - value + return value + } - fun permute(value: Int, permTable: ByteArray, permTableLen: Int, iterCount: Int): Int { - var newValue = value % permTableLen - if (iterCount == 0) return newValue - return permute(permTable[newValue].toInt(), permTable, permTableLen, iterCount - 1) - } + fun permute(value: Int, permTable: ByteArray, permTableLen: Int, iterCount: Int): Int { + var newValue = value % permTableLen + if (iterCount == 0) return newValue + return permute(permTable[newValue].toInt(), permTable, permTableLen, iterCount - 1) } }