From ea8fb862f9718ddcaf710a2740d0e36be84b8ec7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 21 Apr 2026 08:17:48 +0000 Subject: [PATCH 1/4] chore(deps): update plugin org.jlleitschuh.gradle.ktlint to v14 --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 8d90af4..7e85848 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,7 @@ plugins { kotlin("multiplatform") version "2.3.20" kotlin("plugin.serialization") version "2.3.20" - id("org.jlleitschuh.gradle.ktlint") version "12.3.0" + id("org.jlleitschuh.gradle.ktlint") version "14.2.0" } group = "com.monta.slack.notifier" From 16e57296d4884c91750dc3bc1cace89d3428153b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 21 Apr 2026 08:44:54 +0000 Subject: [PATCH 2/4] chore(deps): update plugin org.jlleitschuh.gradle.ktlint to v14 --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 8d90af4..7e85848 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,7 @@ plugins { kotlin("multiplatform") version "2.3.20" kotlin("plugin.serialization") version "2.3.20" - id("org.jlleitschuh.gradle.ktlint") version "12.3.0" + id("org.jlleitschuh.gradle.ktlint") version "14.2.0" } group = "com.monta.slack.notifier" From 0577e97acaa5114a70af35658ca67d14d9dc6a23 Mon Sep 17 00:00:00 2001 From: Morten Andersen Date: Tue, 21 Apr 2026 10:57:18 +0200 Subject: [PATCH 3/4] chore: Applied the upgraded ktlint formatting also added .kotlin to the .gitignore file --- .gitignore | 1 + .../monta/slack/notifier/model/GithubEvent.kt | 19 +++++------ .../monta/slack/notifier/model/JobStatus.kt | 8 ++--- .../com/monta/slack/notifier/model/JobType.kt | 14 +++----- .../monta/slack/notifier/util/FileUtils.kt | 18 ++++------- .../monta/slack/notifier/util/HttpClient.kt | 4 +-- .../monta/slack/notifier/util/StringUtils.kt | 32 ++++++++----------- 7 files changed, 40 insertions(+), 56 deletions(-) diff --git a/.gitignore b/.gitignore index 527b7cf..6ac533a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .gradle /build/ /plugin/build +.kotlin/ # Ignore Gradle GUI config gradle-app.setting diff --git a/src/commonMain/kotlin/com/monta/slack/notifier/model/GithubEvent.kt b/src/commonMain/kotlin/com/monta/slack/notifier/model/GithubEvent.kt index d5c6780..dd4515f 100644 --- a/src/commonMain/kotlin/com/monta/slack/notifier/model/GithubEvent.kt +++ b/src/commonMain/kotlin/com/monta/slack/notifier/model/GithubEvent.kt @@ -10,9 +10,7 @@ class GithubEvent( val workflow: String?, val prUrl: String?, ) { - fun getRunUrl(): String { - return "https://github.com/$repository/actions/runs/$runId" - } + fun getRunUrl(): String = "https://github.com/$repository/actions/runs/$runId" fun getChangeIdentifier(): String? { if (commitSHA != null) { return commitSHA @@ -29,14 +27,13 @@ class GithubEvent( } return "https://github.com/$repository/" } - fun getChangeMessage(): String? { - return message - ?.replace("\n", " ") - ?.replace("\r", " ") - ?.replace("<", "") - ?.replace(">", "") - ?.take(120) - } + fun getChangeMessage(): String? = message + ?.replace("\n", " ") + ?.replace("\r", " ") + ?.replace("<", "") + ?.replace(">", "") + ?.take(120) + fun getPRidentifier(url: String): String? { // Will extract the "pull/51" part of // "https://github.com/monta-app/data-smart-charge/pull/51", diff --git a/src/commonMain/kotlin/com/monta/slack/notifier/model/JobStatus.kt b/src/commonMain/kotlin/com/monta/slack/notifier/model/JobStatus.kt index 6d2c781..db003fa 100644 --- a/src/commonMain/kotlin/com/monta/slack/notifier/model/JobStatus.kt +++ b/src/commonMain/kotlin/com/monta/slack/notifier/model/JobStatus.kt @@ -27,10 +27,8 @@ enum class JobStatus( ; companion object { - fun fromString(value: String?): JobStatus { - return values().find { state -> - state.name.equals(value, true) - } ?: Unknown - } + fun fromString(value: String?): JobStatus = entries.find { state -> + state.name.equals(value, true) + } ?: Unknown } } diff --git a/src/commonMain/kotlin/com/monta/slack/notifier/model/JobType.kt b/src/commonMain/kotlin/com/monta/slack/notifier/model/JobType.kt index d7675ee..e916683 100644 --- a/src/commonMain/kotlin/com/monta/slack/notifier/model/JobType.kt +++ b/src/commonMain/kotlin/com/monta/slack/notifier/model/JobType.kt @@ -18,16 +18,12 @@ enum class JobType( ; companion object { - fun fromString(value: String): JobType { - return JobType.values().find { state -> - state.name.equals(value, true) - } ?: throw RuntimeException("Unknown job type $value") - } + fun fromString(value: String): JobType = entries.find { state -> + state.name.equals(value, true) + } ?: throw RuntimeException("Unknown job type $value") - fun fromLabel(label: String?): JobType? { - return JobType.values().find { state -> - state.label.equals(label, true) - } + fun fromLabel(label: String?): JobType? = entries.find { state -> + state.label.equals(label, true) } } } diff --git a/src/commonMain/kotlin/com/monta/slack/notifier/util/FileUtils.kt b/src/commonMain/kotlin/com/monta/slack/notifier/util/FileUtils.kt index b689900..298a5fd 100644 --- a/src/commonMain/kotlin/com/monta/slack/notifier/util/FileUtils.kt +++ b/src/commonMain/kotlin/com/monta/slack/notifier/util/FileUtils.kt @@ -40,9 +40,7 @@ fun readStringFromFile( * Populates the existing event type with information needed to generate * an entire Slack notification. */ -fun populateEventFromJson(eventJson: String): BaseGithubContext { - return populateOnJsonPush(eventJson) ?: populateOnJsonOpened(eventJson) ?: populateOnJsonCreated(eventJson) ?: handleFailure() -} +fun populateEventFromJson(eventJson: String): BaseGithubContext = populateOnJsonPush(eventJson) ?: populateOnJsonOpened(eventJson) ?: populateOnJsonCreated(eventJson) ?: handleFailure() private fun populateOnJsonPush(eventJson: String): BaseGithubContext? { @Suppress("SwallowedException") @@ -89,11 +87,9 @@ private fun populateOnJsonCreated(eventJson: String): BaseGithubContext? { } } -private fun handleFailure(): BaseGithubContext { - return BaseGithubContext( - displayName = null, - sha = null, - message = null, - prUrl = null - ) -} +private fun handleFailure(): BaseGithubContext = BaseGithubContext( + displayName = null, + sha = null, + message = null, + prUrl = null +) diff --git a/src/commonMain/kotlin/com/monta/slack/notifier/util/HttpClient.kt b/src/commonMain/kotlin/com/monta/slack/notifier/util/HttpClient.kt index b1ed3e9..4ad79d9 100644 --- a/src/commonMain/kotlin/com/monta/slack/notifier/util/HttpClient.kt +++ b/src/commonMain/kotlin/com/monta/slack/notifier/util/HttpClient.kt @@ -4,11 +4,11 @@ import io.ktor.client.* import io.ktor.client.engine.curl.* import io.ktor.client.plugins.contentnegotiation.* import io.ktor.serialization.kotlinx.json.* +import kotlinx.serialization.ExperimentalSerializationApi +import kotlinx.serialization.json.Json import kotlin.experimental.ExperimentalNativeApi import kotlin.native.OsFamily import kotlin.native.Platform -import kotlinx.serialization.ExperimentalSerializationApi -import kotlinx.serialization.json.Json @OptIn(ExperimentalSerializationApi::class, ExperimentalNativeApi::class) val client by lazy { diff --git a/src/commonMain/kotlin/com/monta/slack/notifier/util/StringUtils.kt b/src/commonMain/kotlin/com/monta/slack/notifier/util/StringUtils.kt index a59ec3d..6a96a3f 100644 --- a/src/commonMain/kotlin/com/monta/slack/notifier/util/StringUtils.kt +++ b/src/commonMain/kotlin/com/monta/slack/notifier/util/StringUtils.kt @@ -29,25 +29,21 @@ fun buildTitle( private fun getTitle( serviceName: String?, repository: String?, -): String? { - return if (serviceName.isNullOrBlank()) { - repository.toTitle() - } else { - serviceName - } +): String? = if (serviceName.isNullOrBlank()) { + repository.toTitle() +} else { + serviceName } -private fun String?.toTitle(): String? { - return this?.split("/") - ?.last() - ?.split("-") - ?.joinToString(" ") { word -> - word.replaceFirstChar { firstChar -> - if (firstChar.isLowerCase()) { - firstChar.titlecase() - } else { - firstChar.toString() - } +private fun String?.toTitle(): String? = this?.split("/") + ?.last() + ?.split("-") + ?.joinToString(" ") { word -> + word.replaceFirstChar { firstChar -> + if (firstChar.isLowerCase()) { + firstChar.titlecase() + } else { + firstChar.toString() } } -} + } From 8d01cff489b209d15a5aca9a2fcd242c5b07dd15 Mon Sep 17 00:00:00 2001 From: Morten Andersen Date: Tue, 21 Apr 2026 11:06:18 +0200 Subject: [PATCH 4/4] ignore: Detekt --- .editorconfig | 7 ++++++- .../kotlin/com/monta/slack/notifier/util/FileUtils.kt | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 59aa812..c856203 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,10 +13,15 @@ ij_kotlin_packages_to_use_import_on_demand = io.ktor.** ij_kotlin_name_count_to_use_star_import = 200000000 ij_kotlin_name_count_to_use_star_import_for_members = 2000000000 ij_kotlin_parameter_annotation_wrap = off -ij_kotlin_allow_trailing_comma_on_call_site = false ij_kotlin_allow_trailing_comma = true +ij_kotlin_allow_trailing_comma_on_call_site = false +ktlint_standard_trailing-comma-on-call-site = disabled +ktlint_standard_trailing-comma-on-declaration-site = enabled ktlint_code_style = intellij_idea ktlint_standard_discouraged-comment-location = disabled [{*.markdown,*.md}] ij_wrap_on_typing = true + +[{*.js,*.jsx,*.ts,*.tsx}] +max_line_length = 140 diff --git a/src/commonMain/kotlin/com/monta/slack/notifier/util/FileUtils.kt b/src/commonMain/kotlin/com/monta/slack/notifier/util/FileUtils.kt index 298a5fd..625bf66 100644 --- a/src/commonMain/kotlin/com/monta/slack/notifier/util/FileUtils.kt +++ b/src/commonMain/kotlin/com/monta/slack/notifier/util/FileUtils.kt @@ -40,6 +40,7 @@ fun readStringFromFile( * Populates the existing event type with information needed to generate * an entire Slack notification. */ +@Suppress("detekt:ParameterListWrapping") fun populateEventFromJson(eventJson: String): BaseGithubContext = populateOnJsonPush(eventJson) ?: populateOnJsonOpened(eventJson) ?: populateOnJsonCreated(eventJson) ?: handleFailure() private fun populateOnJsonPush(eventJson: String): BaseGithubContext? {