Skip to content

Commit

Permalink
Fix warning Classes that contain only a companion object should be re…
Browse files Browse the repository at this point in the history
…placed with a named object declaration (#28710)
  • Loading branch information
yufengwangca authored Aug 17, 2023
1 parent e4c82d3 commit d0da504
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions src/controller/java/src/chip/onboardingpayload/Verhoeff.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit d0da504

Please sign in to comment.