[#25] Enable strict Kotlin compiler warnings

Fixed existing warnings, which included:
 - Suppressing a deprecation warning for Java 9, as we have to maintain compatibility with Java 8 for Android
 - Using a new Kotlin API introduced in Kotlin 1.5
 - Removed unused local variables
This commit is contained in:
Carter Jernigan 2022-04-25 11:55:31 -04:00 committed by GitHub
parent 570e273635
commit 90aa3eaf79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 4 deletions

View File

@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m
kotlin.mpp.stability.nowarn=true
BIP39_IS_TREAT_WARNINGS_AS_ERRORS=false
BIP39_IS_TREAT_WARNINGS_AS_ERRORS=true
JVM_TOOLCHAIN=17
JVM_TARGET=1.8

View File

@ -13,6 +13,9 @@ import javax.crypto.spec.SecretKeySpec
* service provider. This provides a bridge to a commonly used Java implementation that has been
* moderately adapted to Kotlin.
*/
// Constructor was deprecated in Java 9, but for compatibility with Android (Java 8, effectively) the old constructor
// must continue to be used.
@Suppress("DEPRECATION")
class FallbackProvider : Provider(
"FallbackProvider",
1.0,

View File

@ -35,7 +35,7 @@ object Pbkdf2Sha512 {
ByteArrayOutputStream().use { baos ->
val dkLenBytes = dkLen/8
val pBytes = p.foldIndexed(ByteArray(p.size)) { i, acc, c ->
acc.apply { this[i] = c.toByte() }
acc.apply { this[i] = c.code.toByte() }
}
val hLen = 20.0
// note: dropped length check because it's redundant, given the size of an int in kotlin

View File

@ -102,7 +102,7 @@ class MnemonicsTest : BehaviorSpec({
row(18, "d5bcbf62dea1a07ab1abb0144b299300137168a7939f3071f112b557", "stick tourist suffer run borrow diary shop invite begin flock gospel ability damage reform oxygen initial corn moon dwarf height image"),
row(15, "e06ce21369dc09eb2bda66510a76f65ab3f947cce90fcb10", "there grow luggage squirrel scene void quarter error extra father rural rely display physical crisp capable slam lumber"),
row(12, "0b01c3c0b0590faf45fc171da17cfb22", "arch asthma usual gaze movie stumble blood load buffalo armor disagree earth")
) { count, entropy, mnemonic ->
) { _, entropy, mnemonic ->
val code = MnemonicCode(entropy.fromHex())
String(code.chars) shouldBe mnemonic
}

View File

@ -11,7 +11,6 @@ import io.kotest.matchers.string.shouldContain
class ReadmeExamplesTest : ShouldSpec({
val validPhrase =
"still champion voice habit trend flight survey between bitter process artefact blind carbon truly provide dizzy crush flush breeze blouse charge solid fish spread"
val validPhraseChars = validPhrase.toCharArray()
context("Example: Create 24-word mnemonic phrase") {
val mnemonicCode = MnemonicCode(WordCount.COUNT_24)
should("result in a valid 24-word phrase") {