From 3dbe4919851709e759f580a55f968b24b697274d Mon Sep 17 00:00:00 2001 From: mikrise2 Date: Thu, 7 Dec 2023 11:32:23 +0100 Subject: [PATCH] [ML4SE-168] Fixed PR comments. --- .../tasktracker/requests/IdRequests.kt | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/requests/IdRequests.kt b/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/requests/IdRequests.kt index bb5598a0..e6717854 100644 --- a/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/requests/IdRequests.kt +++ b/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/requests/IdRequests.kt @@ -22,10 +22,10 @@ object IdRequests { try { return@runBlocking client.submitForm( url = url, - formParameters = parameters { - append("name", name) - append("email", email) - } + formParameters = mapOf( + "name" to name, + "email" to email + ).buildParameters() ).body() } catch (e: Exception) { logger.warn("Server interaction error while getting user id! Url: $url", e) @@ -43,17 +43,23 @@ object IdRequests { requireNotNull(GlobalPluginStorage.userId) { "User id is not defined" } return@runBlocking client.submitForm( url = url, - formParameters = parameters { - append("name", pluginInfoConfig.pluginName) - append("description", pluginInfoConfig.pluginDescription) - append("user_id", GlobalPluginStorage.userId.toString()) - } + formParameters = mapOf( + "name" to pluginInfoConfig.pluginName, + "description" to pluginInfoConfig.pluginDescription, + "user_id" to GlobalPluginStorage.userId.toString() + ).buildParameters() ).body() } catch (e: IllegalArgumentException) { logger.warn(e.localizedMessage) } catch (e: Exception) { - logger.warn("Server interaction error while getting user id! Url: $url", e) + logger.warn("Server interaction error while getting research id! Url: $url", e) } return@runBlocking null } + + private fun Map.buildParameters() = parameters { + this@buildParameters.forEach { (name, param) -> + append(name, param) + } + } }