From 04ceb5134268b254b0a567cf3acca02e2c446877 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 6 Dec 2023 03:17:57 +0000 Subject: [PATCH] chore(deps): update plugin kotlin-qa to v0.56.0 --- .../kotlin/org/protelis/demo/DeviceCapabilities.kt | 2 +- .../src/main/kotlin/org/protelis/demo/HelloProtelis.kt | 4 ++-- .../test/kotlin/org/protelis/demo/KotlinHelloTest.kt | 4 ++-- .../src/main/kotlin/org/protelis/demo/HelloProtelis.kt | 2 +- .../kotlin/org/protelis/demo/SocketNetworkManager.kt | 10 ++++++---- .../test/kotlin/org/protelis/demo/KotlinSocketTest.kt | 2 +- .../src/main/kotlin/org/protelis/demo/HelloProtelis.kt | 2 +- .../kotlin/org/protelis/demo/MqttNetworkManager.kt | 6 +++--- .../test/kotlin/org/protelis/demo/KotlinMqttTest.kt | 2 +- gradle/libs.versions.toml | 2 +- 10 files changed, 19 insertions(+), 17 deletions(-) diff --git a/02-kotlin-helloworld/src/main/kotlin/org/protelis/demo/DeviceCapabilities.kt b/02-kotlin-helloworld/src/main/kotlin/org/protelis/demo/DeviceCapabilities.kt index b8608708..694c0280 100644 --- a/02-kotlin-helloworld/src/main/kotlin/org/protelis/demo/DeviceCapabilities.kt +++ b/02-kotlin-helloworld/src/main/kotlin/org/protelis/demo/DeviceCapabilities.kt @@ -16,7 +16,7 @@ class DeviceCapabilities( private val uid: Int, private val networkManager: NetworkManager, private val codePathFactory: CodePathFactory, - private val speaker: Speaker + private val speaker: Speaker, ) : AbstractExecutionContext(SimpleExecutionEnvironment(), networkManager, codePathFactory), Speaker { diff --git a/02-kotlin-helloworld/src/main/kotlin/org/protelis/demo/HelloProtelis.kt b/02-kotlin-helloworld/src/main/kotlin/org/protelis/demo/HelloProtelis.kt index d36d4d67..995ad9f5 100644 --- a/02-kotlin-helloworld/src/main/kotlin/org/protelis/demo/HelloProtelis.kt +++ b/02-kotlin-helloworld/src/main/kotlin/org/protelis/demo/HelloProtelis.kt @@ -37,7 +37,7 @@ object HelloProtelis { repeat(deviceCount) { g.addEdge( devices[it], - devices[(it + 1) % deviceCount] + devices[(it + 1) % deviceCount], ) } devices.forEach { (it.networkManager as EmulatedNetworkManager).neighbors = Graphs.neighborSetOf(g, it) } @@ -46,7 +46,7 @@ object HelloProtelis { private fun setLeader(id: Int) = devices[id].deviceCapabilities.executionEnvironment.put("leader", true) - private fun syncRunNTimes(n: Int) = repeat(n) { + private fun syncRunNTimes(n: Int) = repeat(n) { _ -> devices.forEach { it.runCycle() } } } diff --git a/02-kotlin-helloworld/src/test/kotlin/org/protelis/demo/KotlinHelloTest.kt b/02-kotlin-helloworld/src/test/kotlin/org/protelis/demo/KotlinHelloTest.kt index 558632e8..0f0f6534 100644 --- a/02-kotlin-helloworld/src/test/kotlin/org/protelis/demo/KotlinHelloTest.kt +++ b/02-kotlin-helloworld/src/test/kotlin/org/protelis/demo/KotlinHelloTest.kt @@ -34,14 +34,14 @@ class KotlinHelloTest : StringSpec() { repeat(n) { g.addEdge( devices[it], - devices[(it + 1) % n] + devices[(it + 1) % n], ) } // Let every device know its neighbors and set the leader devices.forEach { (it.networkManager as EmulatedNetworkManager).neighbors = Graphs.neighborSetOf(g, it) } devices[leader].deviceCapabilities.executionEnvironment.put("leader", true) // Run some cycles - repeat(iterations) { + repeat(iterations) { _ -> devices.forEach { it.runCycle() } } } diff --git a/04-kotlin-socket/src/main/kotlin/org/protelis/demo/HelloProtelis.kt b/04-kotlin-socket/src/main/kotlin/org/protelis/demo/HelloProtelis.kt index 310be55d..34a00246 100644 --- a/04-kotlin-socket/src/main/kotlin/org/protelis/demo/HelloProtelis.kt +++ b/04-kotlin-socket/src/main/kotlin/org/protelis/demo/HelloProtelis.kt @@ -32,7 +32,7 @@ object HelloProtelis { devices += node } // Let the nodes make some iterations. - repeat(iterations) { + repeat(iterations) { _ -> devices.forEach { it.runCycle() } } // Close the thread listening. diff --git a/04-kotlin-socket/src/main/kotlin/org/protelis/demo/SocketNetworkManager.kt b/04-kotlin-socket/src/main/kotlin/org/protelis/demo/SocketNetworkManager.kt index 8af6f2b6..dcfc4be7 100644 --- a/04-kotlin-socket/src/main/kotlin/org/protelis/demo/SocketNetworkManager.kt +++ b/04-kotlin-socket/src/main/kotlin/org/protelis/demo/SocketNetworkManager.kt @@ -21,7 +21,7 @@ class SocketNetworkManager( private val uid: DeviceUID, private val port: Int, private val neighbors: Set, - private val address: String = "127.0.0.1" + private val address: String = "127.0.0.1", ) : NetworkManager { private var messages: Map> = emptyMap() private var running = false @@ -56,7 +56,7 @@ class SocketNetworkManager( override fun failed(exc: Throwable, attachment: Any?) { exc.printStackTrace() } - } + }, ) } try { @@ -96,8 +96,10 @@ class SocketNetworkManager( var client: AsynchronousSocketChannel? = null var oos: ObjectOutputStream? = null try { - client = AsynchronousSocketChannel.open() - val future = client!!.connect(InetSocketAddress(n.host, n.port)) + client = checkNotNull(AsynchronousSocketChannel.open()) { + "Cannot open an asynchronous socket channel" + } + val future = client.connect(InetSocketAddress(n.host, n.port)) future.get() oos = ObjectOutputStream(Channels.newOutputStream(client)) oos.writeObject(message) diff --git a/04-kotlin-socket/src/test/kotlin/org/protelis/demo/KotlinSocketTest.kt b/04-kotlin-socket/src/test/kotlin/org/protelis/demo/KotlinSocketTest.kt index 7fd9d720..e1ece2f6 100644 --- a/04-kotlin-socket/src/test/kotlin/org/protelis/demo/KotlinSocketTest.kt +++ b/04-kotlin-socket/src/test/kotlin/org/protelis/demo/KotlinSocketTest.kt @@ -38,7 +38,7 @@ class KotlinSocketTest : StringSpec() { devices += d speakers += s } - repeat(iterations) { + repeat(iterations) { _ -> devices.forEach { it.runCycle() } } devices.forEach { (it.networkManager as SocketNetworkManager).stop() } diff --git a/06-kotlin-mqtt/src/main/kotlin/org/protelis/demo/HelloProtelis.kt b/06-kotlin-mqtt/src/main/kotlin/org/protelis/demo/HelloProtelis.kt index 793d8b98..796776e6 100644 --- a/06-kotlin-mqtt/src/main/kotlin/org/protelis/demo/HelloProtelis.kt +++ b/06-kotlin-mqtt/src/main/kotlin/org/protelis/demo/HelloProtelis.kt @@ -26,7 +26,7 @@ fun main() { devices += node } // Let the nodes make some iterations. - repeat(iterations) { + repeat(iterations) { _ -> devices.forEach { it.runCycle() } } // Close the thread listening. diff --git a/06-kotlin-mqtt/src/main/kotlin/org/protelis/demo/MqttNetworkManager.kt b/06-kotlin-mqtt/src/main/kotlin/org/protelis/demo/MqttNetworkManager.kt index 59ad6c11..c110716c 100644 --- a/06-kotlin-mqtt/src/main/kotlin/org/protelis/demo/MqttNetworkManager.kt +++ b/06-kotlin-mqtt/src/main/kotlin/org/protelis/demo/MqttNetworkManager.kt @@ -20,11 +20,11 @@ class MqttNetworkManager( address: String = defaultAddress, port: Int = defaultPort, private val qos: Int = defaultQoS, - private val neighbors: Set + private val neighbors: Set, ) : NetworkManager { private var messages: Map> = emptyMap() private val broker = "tcp://$address:$port" - private var mqttClient = MqttAsyncClient(broker, uid.hashCode().toString(), MemoryPersistence()) + private val mqttClient = MqttAsyncClient(broker, uid.hashCode().toString(), MemoryPersistence()) /** * Starts the MQTT client and subscribes to the target topic. @@ -54,7 +54,7 @@ class MqttNetworkManager( * Shutdowns the MQTT client. * @return the token to track the asynchronous task */ - fun stop() = mqttClient.disconnect() + fun stop(): IMqttToken = mqttClient.disconnect() /** * Called by `ProtelisVM` during execution to send its current shared diff --git a/06-kotlin-mqtt/src/test/kotlin/org/protelis/demo/KotlinMqttTest.kt b/06-kotlin-mqtt/src/test/kotlin/org/protelis/demo/KotlinMqttTest.kt index e348a747..84c6af68 100644 --- a/06-kotlin-mqtt/src/test/kotlin/org/protelis/demo/KotlinMqttTest.kt +++ b/06-kotlin-mqtt/src/test/kotlin/org/protelis/demo/KotlinMqttTest.kt @@ -41,7 +41,7 @@ class KotlinMqttTest : StringSpec() { devices += d speakers += s } - repeat(iterations) { + repeat(iterations) { _ -> devices.forEach { it.runCycle() } } devices.forEach { (it.networkManager as MqttNetworkManager).stop() } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 327e9434..c5ab5c80 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -27,6 +27,6 @@ mockito = [ "mockito-core", "mockito-junit-jupiter" ] gitSemVer = "org.danilopianini.git-sensitive-semantic-versioning-gradle-plugin:2.0.4" java-qa = "org.danilopianini.gradle-java-qa:1.28.0" kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } -kotlin-qa = "org.danilopianini.gradle-kotlin-qa:0.29.2" +kotlin-qa = "org.danilopianini.gradle-kotlin-qa:0.56.0" multiJvmTesting = "org.danilopianini.multi-jvm-test-plugin:0.5.6" shadowJar = "com.github.johnrengelman.shadow:8.1.1"