From 09da683ce787872ccfc19fcc77a1abd9729c47aa Mon Sep 17 00:00:00 2001 From: Arie Trouw Date: Tue, 3 Dec 2024 17:08:07 -0800 Subject: [PATCH] Lint --- .../java/network/xyo/client/account/WalletTestVectors.kt | 2 +- sdk/src/androidTest/java/network/xyo/client/lib/Constants.kt | 2 +- .../java/network/xyo/client/node/client/NodeClientTest.kt | 2 +- sdk/src/main/java/network/xyo/client/account/Account.kt | 4 ++-- .../client/archivist/wrapper/ArchivistInsertQueryPayload.kt | 2 +- .../datastore/previous_hash_store/PreviousHashDataStore.kt | 2 +- sdk/src/main/java/network/xyo/client/lib/XyoSerializable.kt | 3 +-- sdk/src/main/java/network/xyo/client/payload/XyoPayload.kt | 2 +- sdk/src/main/java/network/xyo/client/settings/Defaults.kt | 2 +- .../java/network/xyo/client/settings/SettingsInterface.kt | 4 ++-- 10 files changed, 12 insertions(+), 13 deletions(-) diff --git a/sdk/src/androidTest/java/network/xyo/client/account/WalletTestVectors.kt b/sdk/src/androidTest/java/network/xyo/client/account/WalletTestVectors.kt index 36961b7..2a53526 100644 --- a/sdk/src/androidTest/java/network/xyo/client/account/WalletTestVectors.kt +++ b/sdk/src/androidTest/java/network/xyo/client/account/WalletTestVectors.kt @@ -8,7 +8,7 @@ data class TestVector( val address: String, val privateKey: String, val publicKey: String -) {} +) class WalletTestVectors { val phrase = "later puppy sound rebuild rebuild noise ozone amazing hope broccoli crystal grief" diff --git a/sdk/src/androidTest/java/network/xyo/client/lib/Constants.kt b/sdk/src/androidTest/java/network/xyo/client/lib/Constants.kt index bc01136..5c2e425 100644 --- a/sdk/src/androidTest/java/network/xyo/client/lib/Constants.kt +++ b/sdk/src/androidTest/java/network/xyo/client/lib/Constants.kt @@ -9,7 +9,7 @@ class DebugPayload(val nonce: Int) : XyoPayload() { set(value) = Unit } -class BasicPayload(): XyoPayload() { +class BasicPayload : XyoPayload() { override var schema: String get() = "network.xyo.basic" set(value) = Unit diff --git a/sdk/src/androidTest/java/network/xyo/client/node/client/NodeClientTest.kt b/sdk/src/androidTest/java/network/xyo/client/node/client/NodeClientTest.kt index 143c091..0f7e62f 100644 --- a/sdk/src/androidTest/java/network/xyo/client/node/client/NodeClientTest.kt +++ b/sdk/src/androidTest/java/network/xyo/client/node/client/NodeClientTest.kt @@ -13,7 +13,7 @@ import org.junit.Before import org.junit.Test import org.junit.jupiter.api.Assertions.* -class DiscoverPayload(): XyoPayload() { +class DiscoverPayload : XyoPayload() { override var schema = "network.xyo.query.module.discover" } diff --git a/sdk/src/main/java/network/xyo/client/account/Account.kt b/sdk/src/main/java/network/xyo/client/account/Account.kt index e5de77f..87e9c05 100644 --- a/sdk/src/main/java/network/xyo/client/account/Account.kt +++ b/sdk/src/main/java/network/xyo/client/account/Account.kt @@ -15,8 +15,8 @@ import java.security.SecureRandom open class Account private constructor (private val _privateKey: PrivateKey, private var _previousHash: ByteArray? = null): AccountInstance { - constructor(privateKey: ByteArray, previousHash: ByteArray? = null) : this(PrivateKey.fromBytes(privateKey, secp256k1Curve), previousHash) {} - constructor(privateKey: BigInteger, previousHash: ByteArray? = null) : this(privateKey.toByteArray(), previousHash) {} + constructor(privateKey: ByteArray, previousHash: ByteArray? = null) : this(PrivateKey.fromBytes(privateKey, secp256k1Curve), previousHash) + constructor(privateKey: BigInteger, previousHash: ByteArray? = null) : this(privateKey.toByteArray(), previousHash) private val _address = addressFromUncompressedPublicKey(publicKeyUncompressed) diff --git a/sdk/src/main/java/network/xyo/client/archivist/wrapper/ArchivistInsertQueryPayload.kt b/sdk/src/main/java/network/xyo/client/archivist/wrapper/ArchivistInsertQueryPayload.kt index fd03d42..2c079e0 100644 --- a/sdk/src/main/java/network/xyo/client/archivist/wrapper/ArchivistInsertQueryPayload.kt +++ b/sdk/src/main/java/network/xyo/client/archivist/wrapper/ArchivistInsertQueryPayload.kt @@ -3,7 +3,7 @@ package network.xyo.client.archivist.wrapper import network.xyo.client.payload.XyoPayload -class ArchivistInsertQueryPayload(): XyoPayload() { +class ArchivistInsertQueryPayload : XyoPayload() { override var schema = ArchivistInsertQueryPayload.schema companion object { diff --git a/sdk/src/main/java/network/xyo/client/datastore/previous_hash_store/PreviousHashDataStore.kt b/sdk/src/main/java/network/xyo/client/datastore/previous_hash_store/PreviousHashDataStore.kt index 615eff2..4cc7736 100644 --- a/sdk/src/main/java/network/xyo/client/datastore/previous_hash_store/PreviousHashDataStore.kt +++ b/sdk/src/main/java/network/xyo/client/datastore/previous_hash_store/PreviousHashDataStore.kt @@ -13,7 +13,7 @@ import network.xyo.data.PreviousHashPrefsDataStoreProtos import network.xyo.data.PreviousHashPrefsDataStoreProtos.PreviousHashPrefsDataStore import java.io.File -fun Context.xyoPreviousHashDataStore(name: String?, path: String?): DataStore { +fun Context.xyoPreviousHashDataStore(name: String?, path: String?): DataStore { val resolvedName = name ?: defaultXyoSdkSettings.previousHashStorePreferences.fileName val resolvedPath = path ?: defaultXyoSdkSettings.previousHashStorePreferences.storagePath diff --git a/sdk/src/main/java/network/xyo/client/lib/XyoSerializable.kt b/sdk/src/main/java/network/xyo/client/lib/XyoSerializable.kt index 8481be2..c5fa784 100644 --- a/sdk/src/main/java/network/xyo/client/lib/XyoSerializable.kt +++ b/sdk/src/main/java/network/xyo/client/lib/XyoSerializable.kt @@ -40,8 +40,7 @@ abstract class XyoSerializable: Serializable { fun sortJson(jsonArray: JSONArray, removeMeta: Boolean = false): JSONArray { val newJsonArray = JSONArray() for (i in 0 until jsonArray.length()) { - val value = jsonArray[i] - when (value) { + when (val value = jsonArray[i]) { is JSONArray -> { newJsonArray.put(sortJson(value, removeMeta)) } diff --git a/sdk/src/main/java/network/xyo/client/payload/XyoPayload.kt b/sdk/src/main/java/network/xyo/client/payload/XyoPayload.kt index 9bd3e65..ec0946c 100644 --- a/sdk/src/main/java/network/xyo/client/payload/XyoPayload.kt +++ b/sdk/src/main/java/network/xyo/client/payload/XyoPayload.kt @@ -8,7 +8,7 @@ open class XyoValidationException(message: String): XyoException(message) open class XyoInvalidSchemaException(val schema: String): XyoValidationException("'schema' must be lowercase [${schema}]") @JsonClass(generateAdapter = true) -open class XyoPayload(): Payload, XyoSerializable() { +open class XyoPayload : Payload, XyoSerializable() { // Note: Has to be var because "Moshi does not consider a val as a serializable member because // it cannot be symmetrically deserialized." // see - https://github.com/square/moshi/issues/1803 diff --git a/sdk/src/main/java/network/xyo/client/settings/Defaults.kt b/sdk/src/main/java/network/xyo/client/settings/Defaults.kt index 392b873..e6584f5 100644 --- a/sdk/src/main/java/network/xyo/client/settings/Defaults.kt +++ b/sdk/src/main/java/network/xyo/client/settings/Defaults.kt @@ -3,7 +3,7 @@ package network.xyo.client.settings const val DefaultStoragePath = "__xyo-client-sdk__" const val DefaultFileName = "network-xyo-sdk-prefs" -open class DefaultXyoSdkSettings(): SettingsInterface { +open class DefaultXyoSdkSettings : SettingsInterface { override val accountPreferences: AccountPreferences = DefaultAccountPreferences() override val previousHashStorePreferences: PreviousHashStorePreferences = DefaultPreviousHashStorePreferences() } diff --git a/sdk/src/main/java/network/xyo/client/settings/SettingsInterface.kt b/sdk/src/main/java/network/xyo/client/settings/SettingsInterface.kt index 60361b6..a12d005 100644 --- a/sdk/src/main/java/network/xyo/client/settings/SettingsInterface.kt +++ b/sdk/src/main/java/network/xyo/client/settings/SettingsInterface.kt @@ -10,6 +10,6 @@ interface StorageLocationPreference { val storagePath: String? } -interface AccountPreferences: StorageLocationPreference {} +interface AccountPreferences: StorageLocationPreference -interface PreviousHashStorePreferences: StorageLocationPreference {} \ No newline at end of file +interface PreviousHashStorePreferences: StorageLocationPreference \ No newline at end of file