From 8fd14d3795079dc4cad3a8efdbe916f26a69c242 Mon Sep 17 00:00:00 2001 From: Juul Mobile Bot Date: Fri, 18 Aug 2023 09:21:48 +0000 Subject: [PATCH 1/2] Update plugin kotlinter to v3.16.0 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 1b031d3d..721cd27e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -15,6 +15,6 @@ binary-compatibility-validator = { id = "binary-compatibility-validator", versio dokka = { id = "org.jetbrains.dokka", version = "1.8.20" } kotlin-js = { id = "org.jetbrains.kotlin.js", version.ref = "kotlin" } kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } -kotlinter = { id = "org.jmailen.kotlinter", version = "3.15.0" } +kotlinter = { id = "org.jmailen.kotlinter", version = "3.16.0" } kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } maven-publish = { id = "com.vanniktech.maven.publish", version = "0.25.3" } From 50252af2dc5d08f3e0274d7921ad6ced3a0b93c9 Mon Sep 17 00:00:00 2001 From: Travis Wyatt Date: Sat, 19 Aug 2023 21:32:21 -0700 Subject: [PATCH 2/2] Update kotlinter suppression syntax --- koap/src/commonMain/kotlin/Decoder.kt | 12 ++++-------- koap/src/commonMain/kotlin/Encoder.kt | 13 +++---------- koap/src/commonMain/kotlin/Message.kt | 20 ++++++-------------- 3 files changed, 13 insertions(+), 32 deletions(-) diff --git a/koap/src/commonMain/kotlin/Decoder.kt b/koap/src/commonMain/kotlin/Decoder.kt index 280f5d0e..08051142 100644 --- a/koap/src/commonMain/kotlin/Decoder.kt +++ b/koap/src/commonMain/kotlin/Decoder.kt @@ -292,7 +292,7 @@ fun ByteArray.decodeTcpHeader(): Header.Tcp = withReader { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // | Extended Length (if any, as chosen by Len) ... // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - /* ktlint-disable no-multi-spaces */ + @Suppress("ktlint:standard:no-multi-spaces") val length = when (len) { in 0..12 -> len.toLong() // No Extended Length 13 -> (readUByte() + 13).toLong() // 8-bit unsigned integer @@ -300,7 +300,6 @@ fun ByteArray.decodeTcpHeader(): Header.Tcp = withReader { 15 -> readUInt() + 65805 // 32-bit unsigned integer else -> error("Invalid length $len") } - /* ktlint-enable no-multi-spaces */ // |7 6 5 4 3 2 1 0| // +-+-+-+-+-+-+-+-+ @@ -370,27 +369,25 @@ internal fun ByteArrayReader.readOption(preceding: Format?): Option? { // / Option Delta / 0-2 bytes // \ (extended) \ // +-------------------------------+ - /* ktlint-disable no-multi-spaces */ + @Suppress("ktlint:standard:no-multi-spaces") val delta = when (optionDelta) { in 0..12 -> optionDelta // No Extended Delta 13 -> readUByte() + 13 // 8-bit unsigned integer 14 -> readUShort() + 269 // 16-bit unsigned integer else -> error("Invalid option delta $optionDelta") } - /* ktlint-enable no-multi-spaces */ // +-------------------------------+ // / Option Length / 0-2 bytes // \ (extended) \ // +-------------------------------+ - /* ktlint-disable no-multi-spaces */ + @Suppress("ktlint:standard:no-multi-spaces") val length = when (optionLength) { in 0..12 -> optionLength // No Extended Length 13 -> readUByte() + 13 // 8-bit unsigned integer 14 -> readUShort() + 269 // 16-bit unsigned integer else -> error("Invalid option length $optionLength") } - /* ktlint-enable no-multi-spaces */ return when (val number = (preceding?.number ?: 0) + delta) { 1 -> IfMatch(readByteArray(length)) @@ -423,7 +420,7 @@ private fun Int.toType(): Message.Udp.Type = when (this) { else -> error("Unknown message type: $this") } -/* ktlint-disable no-multi-spaces */ +@Suppress("ktlint:standard:no-multi-spaces") private fun Int.toCode(): Message.Code = when (this) { 1 -> GET // 0.01 2 -> POST // 0.02 @@ -459,7 +456,6 @@ private fun Int.toCode(): Message.Code = when (this) { Message.Code.Raw(`class`, detail) } } -/* ktlint-enable no-multi-spaces */ /** * Reads specified number of [bytes] from [ByteArrayReader] receiver to acquire a number. diff --git a/koap/src/commonMain/kotlin/Encoder.kt b/koap/src/commonMain/kotlin/Encoder.kt index a1a0b3fc..a2244a18 100644 --- a/koap/src/commonMain/kotlin/Encoder.kt +++ b/koap/src/commonMain/kotlin/Encoder.kt @@ -171,14 +171,13 @@ internal fun BufferedSink.writeHeader( "Token length of $tokenLength is outside allowable range of $UINT4_RANGE" } - /* ktlint-disable no-multi-spaces */ + @Suppress("ktlint:standard:no-multi-spaces") val len = when { contentLength < 13 -> contentLength // No Extended Length contentLength < 269 -> 13 // Reserved, indicates 8-bit unsigned integer Extended Length contentLength < 65805 -> 14 // Reserved, indicates 16-bit unsigned integer Extended Length else -> 15 // Reserved, indicates 32-bit unsigned integer Extended Length }.toInt() - /* ktlint-enable no-multi-spaces */ val tkl = tokenLength.toInt() // |7 6 5 4 3 2 1 0| @@ -188,7 +187,7 @@ internal fun BufferedSink.writeHeader( writeByte((len shl 4) or tkl) // Extended Length (if any, as chosen by Len) ... - /* ktlint-disable no-multi-spaces */ + @Suppress("ktlint:standard:no-multi-spaces") when (len) { // |7 6 5 4 3 2 1 0| // +-+-+-+-+-+-+-+-+ @@ -208,7 +207,6 @@ internal fun BufferedSink.writeHeader( // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 15 -> writeInt(contentLength - 65805) // 32-bit unsigned integer } - /* ktlint-enable no-multi-spaces */ // |7 6 5 4 3 2 1 0| // +-+-+-+-+-+-+-+-+ @@ -250,16 +248,15 @@ private fun BufferedSink.writeOptions(options: List