From 402a8f55342c4565431c2a2e7287a70592f3fe33 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Thu, 6 Oct 2022 12:51:27 +0200 Subject: style: Eliminate use of wildcard imports This change updates the repository to remove the use of wildcard imports everywhere. Wildcard imports are not allowed by default by Ktlint as well as Google's Java style guide. --- .../main/kotlin/org/opendc/simulator/kotlin/SimulationBuilders.kt | 5 ++++- .../org/opendc/simulator/kotlin/SimulationCoroutineDispatcher.kt | 8 ++++++-- .../src/test/kotlin/org/opendc/simulator/TaskQueueTest.kt | 5 ++++- 3 files changed, 14 insertions(+), 4 deletions(-) (limited to 'opendc-simulator/opendc-simulator-core/src') diff --git a/opendc-simulator/opendc-simulator-core/src/main/kotlin/org/opendc/simulator/kotlin/SimulationBuilders.kt b/opendc-simulator/opendc-simulator-core/src/main/kotlin/org/opendc/simulator/kotlin/SimulationBuilders.kt index c4cc0171..882a0fc5 100644 --- a/opendc-simulator/opendc-simulator-core/src/main/kotlin/org/opendc/simulator/kotlin/SimulationBuilders.kt +++ b/opendc-simulator/opendc-simulator-core/src/main/kotlin/org/opendc/simulator/kotlin/SimulationBuilders.kt @@ -22,7 +22,10 @@ package org.opendc.simulator.kotlin -import kotlinx.coroutines.* +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.Job +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.async import org.opendc.simulator.SimulationScheduler import kotlin.coroutines.ContinuationInterceptor import kotlin.coroutines.CoroutineContext diff --git a/opendc-simulator/opendc-simulator-core/src/main/kotlin/org/opendc/simulator/kotlin/SimulationCoroutineDispatcher.kt b/opendc-simulator/opendc-simulator-core/src/main/kotlin/org/opendc/simulator/kotlin/SimulationCoroutineDispatcher.kt index 21ad1a86..cacbbbf7 100644 --- a/opendc-simulator/opendc-simulator-core/src/main/kotlin/org/opendc/simulator/kotlin/SimulationCoroutineDispatcher.kt +++ b/opendc-simulator/opendc-simulator-core/src/main/kotlin/org/opendc/simulator/kotlin/SimulationCoroutineDispatcher.kt @@ -22,11 +22,15 @@ package org.opendc.simulator.kotlin -import kotlinx.coroutines.* +import kotlinx.coroutines.CancellableContinuation +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.Delay +import kotlinx.coroutines.DisposableHandle +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.InternalCoroutinesApi import org.opendc.simulator.SimulationScheduler import java.lang.Runnable import java.time.Clock -import java.util.* import kotlin.coroutines.CoroutineContext /** diff --git a/opendc-simulator/opendc-simulator-core/src/test/kotlin/org/opendc/simulator/TaskQueueTest.kt b/opendc-simulator/opendc-simulator-core/src/test/kotlin/org/opendc/simulator/TaskQueueTest.kt index a4d779cb..f1559ce3 100644 --- a/opendc-simulator/opendc-simulator-core/src/test/kotlin/org/opendc/simulator/TaskQueueTest.kt +++ b/opendc-simulator/opendc-simulator-core/src/test/kotlin/org/opendc/simulator/TaskQueueTest.kt @@ -22,7 +22,10 @@ package org.opendc.simulator -import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Assertions.assertAll +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertFalse +import org.junit.jupiter.api.Assertions.assertNull import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test -- cgit v1.2.3 From 47357afd16f928260db34d4dd3e686fb9ee7c5ff Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Thu, 6 Oct 2022 13:13:10 +0200 Subject: build: Switch to Spotless for formatting This change updates the build configuration to use Spotless for code formating of both Kotlin and Java. --- .../java/org/opendc/simulator/SimulationScheduler.java | 5 +++-- .../src/main/java/org/opendc/simulator/TaskQueue.java | 10 ++++++---- .../test/kotlin/org/opendc/simulator/TaskQueueTest.kt | 16 ++++++++-------- 3 files changed, 17 insertions(+), 14 deletions(-) (limited to 'opendc-simulator/opendc-simulator-core/src') diff --git a/opendc-simulator/opendc-simulator-core/src/main/java/org/opendc/simulator/SimulationScheduler.java b/opendc-simulator/opendc-simulator-core/src/main/java/org/opendc/simulator/SimulationScheduler.java index a70c1cda..305bdf5e 100644 --- a/opendc-simulator/opendc-simulator-core/src/main/java/org/opendc/simulator/SimulationScheduler.java +++ b/opendc-simulator/opendc-simulator-core/src/main/java/org/opendc/simulator/SimulationScheduler.java @@ -67,7 +67,7 @@ public final class SimulationScheduler implements Executor { * @param initialTimeMs The initial virtual time of the scheduler in milliseconds since epoch. */ public SimulationScheduler(long initialTimeMs) { - this.currentTime = initialTimeMs; + this.currentTime = initialTimeMs; } /** @@ -104,7 +104,8 @@ public final class SimulationScheduler implements Executor { */ public int schedule(long delayMs, Runnable task) { if (delayMs < 0) { - throw new IllegalArgumentException("Attempted scheduling an event earlier in time (delay " + delayMs + " ms)"); + throw new IllegalArgumentException( + "Attempted scheduling an event earlier in time (delay " + delayMs + " ms)"); } long target = currentTime + delayMs; diff --git a/opendc-simulator/opendc-simulator-core/src/main/java/org/opendc/simulator/TaskQueue.java b/opendc-simulator/opendc-simulator-core/src/main/java/org/opendc/simulator/TaskQueue.java index 7d867b5d..f677e74e 100644 --- a/opendc-simulator/opendc-simulator-core/src/main/java/org/opendc/simulator/TaskQueue.java +++ b/opendc-simulator/opendc-simulator-core/src/main/java/org/opendc/simulator/TaskQueue.java @@ -193,7 +193,8 @@ final class TaskQueue { /** * Sift up an entry in the heap. */ - private static void siftUp(long[] deadlines, int[] ids, Runnable[] tasks, int k, long deadline, int id, Runnable task) { + private static void siftUp( + long[] deadlines, int[] ids, Runnable[] tasks, int k, long deadline, int id, Runnable task) { while (k > 0) { int parent = (k - 1) >>> 1; long parentDeadline = deadlines[parent]; @@ -218,11 +219,12 @@ final class TaskQueue { /** * Sift down an entry in the heap. */ - private static void siftDown(long[] deadlines, int[] ids, Runnable[] tasks, int k, int n, long deadline, int id, Runnable task) { - int half = n >>> 1; // loop while a non-leaf + private static void siftDown( + long[] deadlines, int[] ids, Runnable[] tasks, int k, int n, long deadline, int id, Runnable task) { + int half = n >>> 1; // loop while a non-leaf while (k < half) { - int child = (k << 1) + 1; // assume left child is least + int child = (k << 1) + 1; // assume left child is least long childDeadline = deadlines[child]; int childId = ids[child]; diff --git a/opendc-simulator/opendc-simulator-core/src/test/kotlin/org/opendc/simulator/TaskQueueTest.kt b/opendc-simulator/opendc-simulator-core/src/test/kotlin/org/opendc/simulator/TaskQueueTest.kt index f1559ce3..56dd83aa 100644 --- a/opendc-simulator/opendc-simulator-core/src/test/kotlin/org/opendc/simulator/TaskQueueTest.kt +++ b/opendc-simulator/opendc-simulator-core/src/test/kotlin/org/opendc/simulator/TaskQueueTest.kt @@ -47,7 +47,7 @@ class TaskQueueTest { fun testPollEmpty() { assertAll( { assertEquals(Long.MAX_VALUE, queue.peekDeadline()) }, - { assertNull(queue.poll()) }, + { assertNull(queue.poll()) } ) } @@ -63,7 +63,7 @@ class TaskQueueTest { assertAll( { assertEquals(100, queue.peekDeadline()) }, { assertEquals(entry, queue.poll()) }, - { assertNull(queue.poll()) }, + { assertNull(queue.poll()) } ) } @@ -86,7 +86,7 @@ class TaskQueueTest { { assertEquals(entryB, queue.poll()) }, { assertEquals(entryC, queue.poll()) }, { assertEquals(entryA, queue.poll()) }, - { assertNull(queue.poll()) }, + { assertNull(queue.poll()) } ) } @@ -109,7 +109,7 @@ class TaskQueueTest { { assertEquals(entryA, queue.poll()) }, { assertEquals(entryB, queue.poll()) }, { assertEquals(entryC, queue.poll()) }, - { assertNull(queue.poll()) }, + { assertNull(queue.poll()) } ) } @@ -136,7 +136,7 @@ class TaskQueueTest { { assertEquals(entryD, queue.poll()) }, { assertEquals(entryC, queue.poll()) }, { assertEquals(entryA, queue.poll()) }, - { assertNull(queue.poll()) }, + { assertNull(queue.poll()) } ) } @@ -160,7 +160,7 @@ class TaskQueueTest { { assertEquals(20, queue.peekDeadline()) }, { assertEquals(entryB, queue.poll()) }, { assertEquals(entryC, queue.poll()) }, - { assertNull(queue.poll()) }, + { assertNull(queue.poll()) } ) } @@ -184,7 +184,7 @@ class TaskQueueTest { { assertEquals(58, queue.peekDeadline()) }, { assertEquals(entryC, queue.poll()) }, { assertEquals(entryA, queue.poll()) }, - { assertNull(queue.poll()) }, + { assertNull(queue.poll()) } ) } @@ -208,7 +208,7 @@ class TaskQueueTest { { assertEquals(20, queue.peekDeadline()) }, { assertEquals(entryB, queue.poll()) }, { assertEquals(entryA, queue.poll()) }, - { assertNull(queue.poll()) }, + { assertNull(queue.poll()) } ) } -- cgit v1.2.3