From 360293d65f3377a1b1f1133c767e07a21b0a85bb Mon Sep 17 00:00:00 2001 From: Andre Dietisheim Date: Mon, 15 Sep 2025 21:16:54 +0200 Subject: [PATCH] replaced String.format() by kotlin string templates Signed-off-by: Andre Dietisheim --- .../redhat/devtools/gateway/DevSpacesConnection.kt | 2 +- .../devtools/gateway/openshift/DevWorkspaces.kt | 2 +- .../devtools/gateway/server/RemoteIDEServer.kt | 14 +++----------- .../view/steps/DevSpacesWorkspacesStepView.kt | 7 +------ 4 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/main/kotlin/com/redhat/devtools/gateway/DevSpacesConnection.kt b/src/main/kotlin/com/redhat/devtools/gateway/DevSpacesConnection.kt index e57b2bf9..4b2fa601 100644 --- a/src/main/kotlin/com/redhat/devtools/gateway/DevSpacesConnection.kt +++ b/src/main/kotlin/com/redhat/devtools/gateway/DevSpacesConnection.kt @@ -30,7 +30,7 @@ class DevSpacesConnection(private val devSpacesContext: DevSpacesContext) { onDevWorkspaceStopped: () -> Unit, ): ThinClientHandle { if (devSpacesContext.isConnected) - throw IOException(String.format("Already connected to %s", devSpacesContext.devWorkspace.name)) + throw IOException("Already connected to ${devSpacesContext.devWorkspace.name}") devSpacesContext.isConnected = true try { diff --git a/src/main/kotlin/com/redhat/devtools/gateway/openshift/DevWorkspaces.kt b/src/main/kotlin/com/redhat/devtools/gateway/openshift/DevWorkspaces.kt index 17dd52b5..db7db902 100644 --- a/src/main/kotlin/com/redhat/devtools/gateway/openshift/DevWorkspaces.kt +++ b/src/main/kotlin/com/redhat/devtools/gateway/openshift/DevWorkspaces.kt @@ -100,7 +100,7 @@ class DevWorkspaces(private val client: ApiClient) { ): Boolean { var phaseIsDesiredState = false - val watcher = createWatcher(namespace, String.format("metadata.name=%s", name)) + val watcher = createWatcher(namespace, "metadata.name=$name") val executor = Executors.newSingleThreadScheduledExecutor() executor.schedule( { diff --git a/src/main/kotlin/com/redhat/devtools/gateway/server/RemoteIDEServer.kt b/src/main/kotlin/com/redhat/devtools/gateway/server/RemoteIDEServer.kt index 2f2e5f45..f3e7d466 100644 --- a/src/main/kotlin/com/redhat/devtools/gateway/server/RemoteIDEServer.kt +++ b/src/main/kotlin/com/redhat/devtools/gateway/server/RemoteIDEServer.kt @@ -72,10 +72,7 @@ class RemoteIDEServer(private val devSpacesContext: DevSpacesContext) { doWaitServerState(true) .also { if (!it) throw IOException( - String.format( - "Remote IDE server is not ready after %d seconds.", - readyTimeout - ) + "Remote IDE server is not ready after $readyTimeout seconds.", ) } } @@ -109,10 +106,7 @@ class RemoteIDEServer(private val devSpacesContext: DevSpacesContext) { devSpacesContext.devWorkspace.namespace, selector ) ?: throw IOException( - String.format( - "DevWorkspace '%s' is not running.", - devSpacesContext.devWorkspace.name - ) + "DevWorkspace '${devSpacesContext.devWorkspace.name}' is not running.", ) } @@ -120,9 +114,7 @@ class RemoteIDEServer(private val devSpacesContext: DevSpacesContext) { private fun findContainer(): V1Container { return pod.spec!!.containers.find { container -> container.ports?.any { port -> port.name == "idea-server" } != null } ?: throw IOException( - String.format( - "Remote server container not found in the Pod: %s", pod.metadata?.name - ) + "Remote server container not found in the Pod: ${pod.metadata?.name}" ) } } diff --git a/src/main/kotlin/com/redhat/devtools/gateway/view/steps/DevSpacesWorkspacesStepView.kt b/src/main/kotlin/com/redhat/devtools/gateway/view/steps/DevSpacesWorkspacesStepView.kt index 14c09de6..6d829ffc 100644 --- a/src/main/kotlin/com/redhat/devtools/gateway/view/steps/DevSpacesWorkspacesStepView.kt +++ b/src/main/kotlin/com/redhat/devtools/gateway/view/steps/DevSpacesWorkspacesStepView.kt @@ -251,12 +251,7 @@ class DevSpacesWorkspacesStepView(private var devSpacesContext: DevSpacesContext cellHasFocus: Boolean ): Component { return JBLabel( - String.format( - "[%s] %s %s", - devWorkspace.phase, - if (!multipleNamespaces) "" else (devWorkspace.namespace + " /"), - devWorkspace.name - ) + "[${devWorkspace.phase}] ${if (!multipleNamespaces) "" else "${devWorkspace.namespace} /"} ${devWorkspace.name}" ).also { it.font = JBFont.h4().asPlain() }