From 10637633bda66fd0dd01f8990b212fefc3e7c075 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Jan 2024 16:27:51 +0000 Subject: [PATCH 1/5] Bump org.jetbrains.kotlinx.binary-compatibility-validator Bumps [org.jetbrains.kotlinx.binary-compatibility-validator](https://github.com/Kotlin/binary-compatibility-validator) from 0.13.2 to 0.14.0. - [Release notes](https://github.com/Kotlin/binary-compatibility-validator/releases) - [Commits](https://github.com/Kotlin/binary-compatibility-validator/compare/0.13.2...0.14.0) --- updated-dependencies: - dependency-name: org.jetbrains.kotlinx.binary-compatibility-validator dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 29e2381..e29f7bb 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -19,7 +19,7 @@ kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } spotless = { id = "com.diffplug.spotless", version = "6.25.0" } -binaryCompatibilityValidator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version = "0.13.2" } +binaryCompatibilityValidator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version = "0.14.0" } retry = { id = "org.gradle.test-retry", version = "1.5.8" } [libraries] From 56d3780b8fec11ec74338ee7fc71bca4133473dd Mon Sep 17 00:00:00 2001 From: Zac Sweers Date: Sat, 3 Feb 2024 17:21:31 -0500 Subject: [PATCH 2/5] ktfmt 0.47 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e29f7bb..339a144 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,7 +2,7 @@ kotlin = "1.9.22" kotlinx-serialization = "1.6.2" ksp = "1.9.22-1.0.17" -ktfmt = "0.46" +ktfmt = "0.47" jvmTarget = "17" moshix = "0.25.1" moshi = "1.15.0" From 9c5bf454e8a57adfb68c8cb34a98b51253b4a153 Mon Sep 17 00:00:00 2001 From: Zac Sweers Date: Sat, 3 Feb 2024 17:21:41 -0500 Subject: [PATCH 3/5] JDK 21 --- .github/workflows/ci.yml | 2 +- build.gradle.kts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 47b890e..fd78671 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: '20' + java-version: '21' - name: Build and test uses: gradle/gradle-build-action@v2 diff --git a/build.gradle.kts b/build.gradle.kts index 57224ab..18dd6cd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -57,7 +57,7 @@ spotless { } } -configure { toolchain { languageVersion.set(JavaLanguageVersion.of(20)) } } +configure { toolchain { languageVersion.set(JavaLanguageVersion.of(21)) } } tasks.withType().configureEach { options.release.set(libs.versions.jvmTarget.get().toInt()) From 0f855abaa12a671874fd42d7b237dfaf6b634e8d Mon Sep 17 00:00:00 2001 From: Zac Sweers Date: Sat, 3 Feb 2024 17:21:48 -0500 Subject: [PATCH 4/5] Regen API --- api/kotlin-cli-util.api | 4 ---- 1 file changed, 4 deletions(-) diff --git a/api/kotlin-cli-util.api b/api/kotlin-cli-util.api index 81b3305..ba804a1 100644 --- a/api/kotlin-cli-util.api +++ b/api/kotlin-cli-util.api @@ -3502,10 +3502,6 @@ public final class slack/cli/sarif/MergeSarifReports$Factory : slack/cli/Command public fun getKey ()Ljava/lang/String; } -public synthetic class slack/cli/sarif/SarifUtilKt$EntriesMappings { - public static final synthetic field entries$0 Lkotlin/enums/EnumEntries; -} - public final class slack/cli/shellsentry/AnalysisResult { public fun (Ljava/lang/String;Ljava/lang/String;Lslack/cli/shellsentry/RetrySignal;ILkotlin/jvm/functions/Function1;)V public final fun component1 ()Ljava/lang/String; From 5c295352ec3f72d05ec115acdc1eda08c7dc2ad7 Mon Sep 17 00:00:00 2001 From: Zac Sweers Date: Sat, 3 Feb 2024 17:23:25 -0500 Subject: [PATCH 5/5] Spotless --- build.gradle.kts | 2 +- src/main/kotlin/slack/cli/CliUtil.kt | 4 +-- src/main/kotlin/slack/cli/CliktExtensions.kt | 6 ++-- .../cli/buildkite/BuildkiteDataBindings.kt | 10 +++--- .../kotlin/slack/cli/buildkite/Extensions.kt | 8 ++--- .../buildkite/JsonElementKamlSerializers.kt | 8 ++--- .../cli/gradle/GradleProjectFlattenerCli.kt | 2 +- .../cli/gradle/GradleSettingsVerifierCli.kt | 12 +++---- .../slack/cli/lint/LintBaselineMergerCli.kt | 18 +++++------ .../slack/cli/sarif/ApplyBaselinesToSarifs.kt | 4 +-- .../slack/cli/sarif/MergeSarifReports.kt | 8 ++--- src/main/kotlin/slack/cli/sarif/SarifUtil.kt | 4 +-- .../slack/cli/shellsentry/KnownIssues.kt | 16 +++++----- .../cli/shellsentry/OkHttpSyncHttpDelivery.kt | 2 +- .../slack/cli/shellsentry/ShellSentry.kt | 10 +++--- .../slack/cli/shellsentry/ShellSentryCli.kt | 2 +- .../cli/shellsentry/ShellSentryConfig.kt | 2 +- .../cli/shellsentry/ShellSentryExtension.kt | 4 +-- .../kotlin/slack/cli/util/RegexJsonAdapter.kt | 5 ++- .../cli/shellsentry/ResultProcessorTest.kt | 32 ++++++------------- .../cli/shellsentry/ShellSentryCliTest.kt | 2 +- .../cli/shellsentry/ShellSentryConfigTest.kt | 2 +- 22 files changed, 73 insertions(+), 90 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 18dd6cd..197feb2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -52,7 +52,7 @@ spotless { endWithNewline() licenseHeaderFile( "spotless/spotless.kt", - "(import|plugins|buildscript|dependencies|pluginManagement)" + "(import|plugins|buildscript|dependencies|pluginManagement)", ) } } diff --git a/src/main/kotlin/slack/cli/CliUtil.kt b/src/main/kotlin/slack/cli/CliUtil.kt index 9f3c592..108131f 100644 --- a/src/main/kotlin/slack/cli/CliUtil.kt +++ b/src/main/kotlin/slack/cli/CliUtil.kt @@ -75,7 +75,7 @@ public fun Sequence.filterByExtension(extension: String): Sequence { /** Filters by a specific [name]. */ public fun Sequence.filterByName( name: String, - withoutExtension: Boolean = true + withoutExtension: Boolean = true, ): Sequence { return if (withoutExtension) { filter { it.nameWithoutExtension == name } @@ -94,7 +94,7 @@ public fun Sequence.filterByExtension(extension: String): Sequence { @JvmName("filterByNamePath") public fun Sequence.filterByName( name: String, - withoutExtension: Boolean = true + withoutExtension: Boolean = true, ): Sequence { return if (withoutExtension) { filter { it.nameWithoutExtension == name } diff --git a/src/main/kotlin/slack/cli/CliktExtensions.kt b/src/main/kotlin/slack/cli/CliktExtensions.kt index 16464a4..5301f20 100644 --- a/src/main/kotlin/slack/cli/CliktExtensions.kt +++ b/src/main/kotlin/slack/cli/CliktExtensions.kt @@ -16,7 +16,7 @@ @file:Suppress( "LongParameterList", // These are how many parameters are in Clikt options. "SpreadOperator", // Not spreading would change semantics. - "unused" + "unused", ) package slack.cli @@ -34,14 +34,14 @@ import java.nio.file.Paths /** A dry run option for [clikt commands][CliktCommand]. */ public fun CliktCommand.dryRunOption( vararg names: String = arrayOf("--dry-run"), - help: String = "Runs this as a dry run, no modifications." + help: String = "Runs this as a dry run, no modifications.", ): OptionWithValues = option(names = names, help = help).flag(default = false) /** A project dir option for [clikt commands][CliktCommand]. */ public fun CliktCommand.projectDirOption( vararg names: String = arrayOf("--project-dir"), - help: String = "The project directory. Defaults to the current working directory." + help: String = "The project directory. Defaults to the current working directory.", ): OptionDelegate = option(names = names, help = help).path(mustExist = true, canBeFile = false).defaultLazy { Paths.get("").toAbsolutePath() diff --git a/src/main/kotlin/slack/cli/buildkite/BuildkiteDataBindings.kt b/src/main/kotlin/slack/cli/buildkite/BuildkiteDataBindings.kt index d867ff5..8ec6341 100644 --- a/src/main/kotlin/slack/cli/buildkite/BuildkiteDataBindings.kt +++ b/src/main/kotlin/slack/cli/buildkite/BuildkiteDataBindings.kt @@ -130,13 +130,13 @@ public data class ExternalNotification( @Serializable public data class GithubCheck( /** GitHub commit status name */ - val context: String? = null, + val context: String? = null ) @Serializable public data class GithubCommitStatus( /** GitHub commit status name */ - val context: String? = null, + val context: String? = null ) @Serializable @@ -715,7 +715,7 @@ public sealed interface SoftFail { @Serializable public data class SoftFailElement( /** The exit status number that will cause this job to soft-fail */ - @SerialName("exit_status") val exitStatus: ExitStatusUnion? = null, + @SerialName("exit_status") val exitStatus: ExitStatusUnion? = null ) @Serializable @@ -764,9 +764,7 @@ public sealed interface Setup { public sealed interface Plugins { @Serializable @JvmInline - public value class AnythingMapValue( - public val value: JsonObject, - ) : Plugins + public value class AnythingMapValue(public val value: JsonObject) : Plugins @Serializable @JvmInline diff --git a/src/main/kotlin/slack/cli/buildkite/Extensions.kt b/src/main/kotlin/slack/cli/buildkite/Extensions.kt index a3041a0..4207df6 100644 --- a/src/main/kotlin/slack/cli/buildkite/Extensions.kt +++ b/src/main/kotlin/slack/cli/buildkite/Extensions.kt @@ -64,17 +64,15 @@ public object Conditions { public fun githubStatusNotif( context: String, - notifyIf: String = Conditions.NOT_CANCELLING + notifyIf: String = Conditions.NOT_CANCELLING, ): Notification = Notification( ExternalNotification( githubCommitStatus = GithubCommitStatus(context = context), - notifyIf = notifyIf + notifyIf = notifyIf, ) ) public fun CommandStep.withGithubStatus(context: String): CommandStep { - return copy( - notify = listOf(githubStatusNotif(context)), - ) + return copy(notify = listOf(githubStatusNotif(context))) } diff --git a/src/main/kotlin/slack/cli/buildkite/JsonElementKamlSerializers.kt b/src/main/kotlin/slack/cli/buildkite/JsonElementKamlSerializers.kt index 3cc8c43..551e980 100644 --- a/src/main/kotlin/slack/cli/buildkite/JsonElementKamlSerializers.kt +++ b/src/main/kotlin/slack/cli/buildkite/JsonElementKamlSerializers.kt @@ -53,7 +53,7 @@ internal object JsonObjectAsMapSerializer : KSerializer { buildClassSerialDescriptor("JsonObjectAsMap") { element( "properties", - mapSerialDescriptor(String.serializer().descriptor, JsonElementKamlSerializer.descriptor) + mapSerialDescriptor(String.serializer().descriptor, JsonElementKamlSerializer.descriptor), ) } @@ -61,7 +61,7 @@ internal object JsonObjectAsMapSerializer : KSerializer { val map = value.mapValues { it.value } encoder.encodeSerializableValue( MapSerializer(String.serializer(), JsonElementKamlSerializer), - map + map, ) } @@ -132,7 +132,7 @@ internal object JsonPrimitiveSerializer : KSerializer { throw JsonDecodingException( -1, "Unexpected JSON element, expected JsonPrimitive, had ${result::class}", - result.toString() + result.toString(), ) } return result @@ -205,7 +205,7 @@ private object JsonLiteralSerializer : KSerializer { throw JsonDecodingException( -1, "Unexpected JSON element, expected JsonLiteral, had ${result::class}", - result.toString() + result.toString(), ) } return result diff --git a/src/main/kotlin/slack/cli/gradle/GradleProjectFlattenerCli.kt b/src/main/kotlin/slack/cli/gradle/GradleProjectFlattenerCli.kt index 60c308f..b796378 100644 --- a/src/main/kotlin/slack/cli/gradle/GradleProjectFlattenerCli.kt +++ b/src/main/kotlin/slack/cli/gradle/GradleProjectFlattenerCli.kt @@ -68,7 +68,7 @@ public class GradleProjectFlattenerCli : CliktCommand(help = DESCRIPTION) { "-s", help = "The settings.gradle file to use. Note this file _must_ only have a single, top-level `include()` call " + - "with vararg project args." + "with vararg project args.", ) .path(mustExist = true, canBeDir = false) .required() diff --git a/src/main/kotlin/slack/cli/gradle/GradleSettingsVerifierCli.kt b/src/main/kotlin/slack/cli/gradle/GradleSettingsVerifierCli.kt index c5454c2..7f4e7a4 100644 --- a/src/main/kotlin/slack/cli/gradle/GradleSettingsVerifierCli.kt +++ b/src/main/kotlin/slack/cli/gradle/GradleSettingsVerifierCli.kt @@ -61,7 +61,7 @@ public class GradleSettingsVerifierCli : CliktCommand(help = DESCRIPTION) { "-s", help = "The settings.gradle file to use. Note this file _must_ only have a single, top-level `include()` call " + - "with vararg project args." + "with vararg project args.", ) .path(mustExist = true, canBeDir = false) .required() @@ -71,7 +71,7 @@ public class GradleSettingsVerifierCli : CliktCommand(help = DESCRIPTION) { "--implicit-path", "-i", help = - "Implicit project names that may not be present in the settings file but should be assumed present." + "Implicit project names that may not be present in the settings file but should be assumed present.", ) .multiple() @@ -79,7 +79,7 @@ public class GradleSettingsVerifierCli : CliktCommand(help = DESCRIPTION) { option( "--delete-un-included-paths", "-d", - help = "Delete any paths that are not included in the settings file." + help = "Delete any paths that are not included in the settings file.", ) .flag() @@ -143,19 +143,19 @@ public class GradleSettingsVerifierCli : CliktCommand(help = DESCRIPTION) { !realPath.exists() -> { reportError( "Project dir '${realPath.relativeTo(projectDir)}' does not exist.", - line.indexOfFirst { !it.isWhitespace() } + line.indexOfFirst { !it.isWhitespace() }, ) } !realPath.resolve("build.gradle.kts").exists() -> { reportError( "Project build file '${realPath.relativeTo(projectDir).resolve("build.gradle.kts")}' does not exist.", - line.indexOfFirst { !it.isWhitespace() } + line.indexOfFirst { !it.isWhitespace() }, ) } !realPath.isDirectory() -> { reportError( "Expected '$realPath' to be a directory.", - line.indexOfFirst { !it.isWhitespace() } + line.indexOfFirst { !it.isWhitespace() }, ) } } diff --git a/src/main/kotlin/slack/cli/lint/LintBaselineMergerCli.kt b/src/main/kotlin/slack/cli/lint/LintBaselineMergerCli.kt index 23c7b8a..a71daa5 100644 --- a/src/main/kotlin/slack/cli/lint/LintBaselineMergerCli.kt +++ b/src/main/kotlin/slack/cli/lint/LintBaselineMergerCli.kt @@ -93,7 +93,7 @@ public class LintBaselineMergerCli : CliktCommand(DESCRIPTION) { help = "Template for messages with each issue. This message can optionally " + "contain '{id}' in it to be replaced with the issue ID and '{message}' " + - "for the original message." + "for the original message.", ) .default("{message}") @@ -117,7 +117,7 @@ public class LintBaselineMergerCli : CliktCommand(DESCRIPTION) { name = issue.id, shortDescription = MultiformatMessageString(text = issue.message), fullDescription = MultiformatMessageString(text = issue.message), - defaultConfiguration = ReportingConfiguration(level = Level.Error) + defaultConfiguration = ReportingConfiguration(level = Level.Error), ) } .sortedBy { it.id } @@ -141,7 +141,7 @@ public class LintBaselineMergerCli : CliktCommand(DESCRIPTION) { { it.id }, { it.location.file }, { it.location.line }, - { it.location.column } + { it.location.column }, ) ) .map { key -> key to issues.getValue(key) } @@ -157,11 +157,11 @@ public class LintBaselineMergerCli : CliktCommand(DESCRIPTION) { Message( text = messageTemplate.replace("{id}", id).replace("{message}", issue.message) - ) + ), ) - } + }, ) - ) + ), ) SarifSerializer.toJson(outputSarif).let { outputFile.writeText(it) } @@ -212,7 +212,7 @@ public class LintBaselineMergerCli : CliktCommand(DESCRIPTION) { @Serializable(HtmlEscapeStringSerializer::class) val name: String, @Serializable(HtmlEscapeStringSerializer::class) val variant: String, @Serializable(HtmlEscapeStringSerializer::class) val version: String, - val issues: List + val issues: List, ) { @Serializable @XmlSerialName("issue") @@ -269,8 +269,8 @@ public class LintBaselineMergerCli : CliktCommand(DESCRIPTION) { $errorLine2 """ .trimIndent() - ) - ) + ), + ), ) ) } diff --git a/src/main/kotlin/slack/cli/sarif/ApplyBaselinesToSarifs.kt b/src/main/kotlin/slack/cli/sarif/ApplyBaselinesToSarifs.kt index b7282cf..80ad6ac 100644 --- a/src/main/kotlin/slack/cli/sarif/ApplyBaselinesToSarifs.kt +++ b/src/main/kotlin/slack/cli/sarif/ApplyBaselinesToSarifs.kt @@ -65,7 +65,7 @@ public class ApplyBaselinesToSarifs : CliktCommand(help = DESCRIPTION) { "--remove-uri-prefixes", help = "When enabled, removes the root project directory from location uris such that they are only " + - "relative to the root project dir." + "relative to the root project dir.", ) .flag() @@ -172,7 +172,7 @@ public class ApplyBaselinesToSarifs : CliktCommand(help = DESCRIPTION) { newCurrentSchema.mergeWith( absentResultsSchema, removeUriPrefixes = removeUriPrefixes, - log = ::echo + log = ::echo, ) } } diff --git a/src/main/kotlin/slack/cli/sarif/MergeSarifReports.kt b/src/main/kotlin/slack/cli/sarif/MergeSarifReports.kt index 5c4602e..56ed771 100644 --- a/src/main/kotlin/slack/cli/sarif/MergeSarifReports.kt +++ b/src/main/kotlin/slack/cli/sarif/MergeSarifReports.kt @@ -66,7 +66,7 @@ public class MergeSarifReports : CliktCommand(help = DESCRIPTION) { option( "--remap-src-roots", help = - "When enabled, remaps uri roots to include the subproject path (relative to the root project)." + "When enabled, remaps uri roots to include the subproject path (relative to the root project).", ) .flag() @@ -75,7 +75,7 @@ public class MergeSarifReports : CliktCommand(help = DESCRIPTION) { "--remove-uri-prefixes", help = "When enabled, removes the root project directory from location uris such that they are only " + - "relative to the root project dir." + "relative to the root project dir.", ) .flag() @@ -83,7 +83,7 @@ public class MergeSarifReports : CliktCommand(help = DESCRIPTION) { option( "--allow-empty", help = "Flag to allow graceful exiting if no sarif files are found.", - envvar = "SARIF_MERGING_ALLOW_EMPTY" + envvar = "SARIF_MERGING_ALLOW_EMPTY", ) .flag() @@ -229,7 +229,7 @@ public class MergeSarifReports : CliktCommand(help = DESCRIPTION) { ) } ) - } + }, ) } ) diff --git a/src/main/kotlin/slack/cli/sarif/SarifUtil.kt b/src/main/kotlin/slack/cli/sarif/SarifUtil.kt index 4d9c1a6..92b24e6 100644 --- a/src/main/kotlin/slack/cli/sarif/SarifUtil.kt +++ b/src/main/kotlin/slack/cli/sarif/SarifUtil.kt @@ -29,7 +29,7 @@ import java.util.Objects internal val BASELINE_SUPPRESSION: Suppression = Suppression( kind = SuppressionKind.External, - justification = "This issue was suppressed by the baseline" + justification = "This issue was suppressed by the baseline", ) /** @@ -97,7 +97,7 @@ internal fun CliktCommand.levelOption(): NullableOption { return option( "--level", "-l", - help = "Priority level. Defaults to Error. Options are $LEVEL_NAMES" + help = "Priority level. Defaults to Error. Options are $LEVEL_NAMES", ) .enum() } diff --git a/src/main/kotlin/slack/cli/shellsentry/KnownIssues.kt b/src/main/kotlin/slack/cli/shellsentry/KnownIssues.kt index fd1fe37..ec07141 100644 --- a/src/main/kotlin/slack/cli/shellsentry/KnownIssues.kt +++ b/src/main/kotlin/slack/cli/shellsentry/KnownIssues.kt @@ -30,7 +30,7 @@ internal object KnownIssues { matchingText = listOf("FAKE FAILURE NOT REAL"), matchingPatterns = listOf(".*FAKE_FAILURE_[a-zA-Z].*".toRegex()), groupingHash = "fake-failure", - retrySignal = RetrySignal.Ack + retrySignal = RetrySignal.Ack, ) val ftlRateLimit = @@ -39,7 +39,7 @@ internal object KnownIssues { matchingText = listOf("429 Too Many Requests"), logMessage = "Detected FTL rate limit. Retrying in 1 minute.", groupingHash = "ftl-rate-limit", - retrySignal = RetrySignal.RetryDelayed(1.minutes) + retrySignal = RetrySignal.RetryDelayed(1.minutes), ) val oom = @@ -48,7 +48,7 @@ internal object KnownIssues { matchingText = listOf("Java heap space"), logMessage = "Detected OOM. Retrying immediately.", groupingHash = OOM_GROUPING_HASH, - retrySignal = RetrySignal.RetryImmediately + retrySignal = RetrySignal.RetryImmediately, ) val ftlInfrastructureFailure = @@ -57,7 +57,7 @@ internal object KnownIssues { matchingText = listOf("Infrastructure failure"), logMessage = "Detected inconclusive FTL infrastructure failure. Retrying immediately.", groupingHash = "ftl-infrastructure-failure", - retrySignal = RetrySignal.RetryImmediately + retrySignal = RetrySignal.RetryImmediately, ) val flankTimeout = @@ -66,7 +66,7 @@ internal object KnownIssues { groupingHash = "flank-timeout", matchingText = listOf("Canceling flank due to timeout"), logMessage = "Detected a flank timeout. Retrying immediately.", - retrySignal = RetrySignal.RetryImmediately + retrySignal = RetrySignal.RetryImmediately, ) val r8Oom = @@ -75,7 +75,7 @@ internal object KnownIssues { matchingText = listOf("Out of space in CodeCache"), logMessage = "Detected a OOM in R8. Retrying immediately.", groupingHash = OOM_GROUPING_HASH, - retrySignal = RetrySignal.RetryImmediately + retrySignal = RetrySignal.RetryImmediately, ) val oomKilledByKernel = @@ -84,7 +84,7 @@ internal object KnownIssues { groupingHash = OOM_GROUPING_HASH, matchingText = listOf("Gradle build daemon disappeared unexpectedly"), logMessage = "Detected a OOM that was killed by the kernel. Retrying immediately.", - retrySignal = RetrySignal.RetryImmediately + retrySignal = RetrySignal.RetryImmediately, ) val bugsnagUploadFailed = @@ -93,6 +93,6 @@ internal object KnownIssues { groupingHash = "bugsnag-upload-failure", matchingText = listOf("Bugsnag request failed to complete"), logMessage = "Detected bugsnag failed to upload. Retrying immediately.", - retrySignal = RetrySignal.RetryImmediately + retrySignal = RetrySignal.RetryImmediately, ) } diff --git a/src/main/kotlin/slack/cli/shellsentry/OkHttpSyncHttpDelivery.kt b/src/main/kotlin/slack/cli/shellsentry/OkHttpSyncHttpDelivery.kt index d106c19..6dbf34d 100644 --- a/src/main/kotlin/slack/cli/shellsentry/OkHttpSyncHttpDelivery.kt +++ b/src/main/kotlin/slack/cli/shellsentry/OkHttpSyncHttpDelivery.kt @@ -61,7 +61,7 @@ internal object OkHttpSyncHttpDelivery : HttpDelivery { if (!response.isSuccessful) { LOGGER.warn( "Error not reported to Bugsnag - got non-200 response code: {}", - response.code + response.code, ) } } diff --git a/src/main/kotlin/slack/cli/shellsentry/ShellSentry.kt b/src/main/kotlin/slack/cli/shellsentry/ShellSentry.kt index 2eee1f7..5c7e7fe 100644 --- a/src/main/kotlin/slack/cli/shellsentry/ShellSentry.kt +++ b/src/main/kotlin/slack/cli/shellsentry/ShellSentry.kt @@ -53,7 +53,7 @@ public data class ShellSentry( private val debug: Boolean = false, private val noExit: Boolean = false, private val logger: (String) -> Unit = ::println, - private val extensions: List = emptyList() + private val extensions: List = emptyList(), ) { @Suppress("CyclomaticComplexMethod", "LongMethod") @@ -94,7 +94,7 @@ public data class ShellSentry( command, secondResult.exitCode, secondResult.outputFile, - isAfterRetry = true + isAfterRetry = true, ) } } @@ -110,7 +110,7 @@ public data class ShellSentry( command, secondResult.exitCode, secondResult.outputFile, - isAfterRetry = true + isAfterRetry = true, ) } } @@ -143,7 +143,7 @@ public data class ShellSentry( /** Internal function to consolidate CLI args -> [ShellSentry] creation logic. */ internal fun create( cli: ShellSentryCli, - logger: (String) -> Unit = { cli.echo(it) } + logger: (String) -> Unit = { cli.echo(it) }, ): ShellSentry { val moshi = ProcessingUtil.newMoshi() val config = @@ -165,7 +165,7 @@ public data class ShellSentry( bugsnagKey = cli.bugsnagKey, debug = cli.debug, noExit = cli.noExit, - logger = logger + logger = logger, ) } } diff --git a/src/main/kotlin/slack/cli/shellsentry/ShellSentryCli.kt b/src/main/kotlin/slack/cli/shellsentry/ShellSentryCli.kt index 8830a89..620aba7 100644 --- a/src/main/kotlin/slack/cli/shellsentry/ShellSentryCli.kt +++ b/src/main/kotlin/slack/cli/shellsentry/ShellSentryCli.kt @@ -65,7 +65,7 @@ public class ShellSentryCli : CliktCommand(DESCRIPTION) { internal val noExit by option( "--no-exit", - help = "Instructs this CLI to not exit the process with the status code. Test only!" + help = "Instructs this CLI to not exit the process with the status code. Test only!", ) .flag() diff --git a/src/main/kotlin/slack/cli/shellsentry/ShellSentryConfig.kt b/src/main/kotlin/slack/cli/shellsentry/ShellSentryConfig.kt index 635e7c5..c804469 100644 --- a/src/main/kotlin/slack/cli/shellsentry/ShellSentryConfig.kt +++ b/src/main/kotlin/slack/cli/shellsentry/ShellSentryConfig.kt @@ -33,7 +33,7 @@ public data class ShellSentryConfig( * A minimum confidence level on a scale of [0-100] to accept. [AnalysisResult]s from * [ShellSentryExtension]s with lower confidence than this will be discarded. */ - @Json(name = "min_confidence") val minConfidence: Int = 75 + @Json(name = "min_confidence") val minConfidence: Int = 75, ) { init { check(version == CURRENT_VERSION) { diff --git a/src/main/kotlin/slack/cli/shellsentry/ShellSentryExtension.kt b/src/main/kotlin/slack/cli/shellsentry/ShellSentryExtension.kt index 80f0175..b2f64ba 100644 --- a/src/main/kotlin/slack/cli/shellsentry/ShellSentryExtension.kt +++ b/src/main/kotlin/slack/cli/shellsentry/ShellSentryExtension.kt @@ -52,7 +52,7 @@ public fun interface ShellSentryExtension { command: String, exitCode: Int, isAfterRetry: Boolean, - consoleOutput: Path + consoleOutput: Path, ): AnalysisResult? } @@ -76,5 +76,5 @@ public data class AnalysisResult( * A function that takes the [message] and returns a [Throwable] for reporting to Bugsnag. * Consider subclassing [NoStacktraceThrowable] if needed. */ - val throwableMaker: (message: String) -> Throwable + val throwableMaker: (message: String) -> Throwable, ) diff --git a/src/main/kotlin/slack/cli/util/RegexJsonAdapter.kt b/src/main/kotlin/slack/cli/util/RegexJsonAdapter.kt index 9011fb8..129ee2f 100644 --- a/src/main/kotlin/slack/cli/util/RegexJsonAdapter.kt +++ b/src/main/kotlin/slack/cli/util/RegexJsonAdapter.kt @@ -24,9 +24,8 @@ import com.squareup.moshi.rawType import java.lang.reflect.Type /** A simple [Regex] adapter that converts Strings to a [Regex]. */ -internal class RegexJsonAdapter( - private val stringAdapter: JsonAdapter, -) : JsonAdapter() { +internal class RegexJsonAdapter(private val stringAdapter: JsonAdapter) : + JsonAdapter() { override fun fromJson(reader: JsonReader) = stringAdapter.fromJson(reader)!!.toRegex() override fun toJson(writer: JsonWriter, value: Regex?) { diff --git a/src/test/kotlin/slack/cli/shellsentry/ResultProcessorTest.kt b/src/test/kotlin/slack/cli/shellsentry/ResultProcessorTest.kt index 2bfe83d..51c65c4 100644 --- a/src/test/kotlin/slack/cli/shellsentry/ResultProcessorTest.kt +++ b/src/test/kotlin/slack/cli/shellsentry/ResultProcessorTest.kt @@ -27,18 +27,13 @@ import org.junit.runners.Parameterized import org.junit.runners.Parameterized.Parameters @RunWith(Parameterized::class) -class ResultProcessorTest( - private val useExtensions: Boolean, -) { +class ResultProcessorTest(private val useExtensions: Boolean) { companion object { @Parameters(name = "useExtensions = {0}") @JvmStatic fun data(): List> { - return listOf( - arrayOf(true), - arrayOf(false), - ) + return listOf(arrayOf(true), arrayOf(false)) } } @@ -47,19 +42,14 @@ class ResultProcessorTest( private val logs = ArrayDeque() private val testExtensions = - listOf( - KnownIssues.ftlRateLimit, - KnownIssues.oom, - KnownIssues.fakeFailure, - ) - .map { issue -> - ShellSentryExtension { _, _, _, consoleOutput -> - val signal = issue.check(consoleOutput.readLines(), logs::add) - // Give all these 75% confidence. Higher than the default, but not 100 so we can test - // higher confidence later - AnalysisResult(issue.message, issue.logMessage, signal, 75) { KnownIssue(issue) } - } + listOf(KnownIssues.ftlRateLimit, KnownIssues.oom, KnownIssues.fakeFailure).map { issue -> + ShellSentryExtension { _, _, _, consoleOutput -> + val signal = issue.check(consoleOutput.readLines(), logs::add) + // Give all these 75% confidence. Higher than the default, but not 100 so we can test + // higher confidence later + AnalysisResult(issue.message, issue.logMessage, signal, 75) { KnownIssue(issue) } } + } @Test fun testExecuteCommand() { @@ -208,9 +198,7 @@ class ResultProcessorTest( FAKE_FAILURE_a """.trimIndent().padWithTestLogs()) val signal = - newProcessor( - config = ShellSentryConfig(knownIssues = emptyList(), minConfidence = 100), - ) + newProcessor(config = ShellSentryConfig(knownIssues = emptyList(), minConfidence = 100)) .process("", 1, outputFile.toPath(), isAfterRetry = false) check(signal is RetrySignal.Unknown) } diff --git a/src/test/kotlin/slack/cli/shellsentry/ShellSentryCliTest.kt b/src/test/kotlin/slack/cli/shellsentry/ShellSentryCliTest.kt index b66f462..aa949c2 100644 --- a/src/test/kotlin/slack/cli/shellsentry/ShellSentryCliTest.kt +++ b/src/test/kotlin/slack/cli/shellsentry/ShellSentryCliTest.kt @@ -40,7 +40,7 @@ class ShellSentryCliTest { "--config", configFile.absolutePath, "--", - args + args, ) ) } diff --git a/src/test/kotlin/slack/cli/shellsentry/ShellSentryConfigTest.kt b/src/test/kotlin/slack/cli/shellsentry/ShellSentryConfigTest.kt index 338e9c6..ef9b9f6 100644 --- a/src/test/kotlin/slack/cli/shellsentry/ShellSentryConfigTest.kt +++ b/src/test/kotlin/slack/cli/shellsentry/ShellSentryConfigTest.kt @@ -53,7 +53,7 @@ class ShellSentryConfigTest { ShellSentryConfig( CURRENT_VERSION, "https://gradle-enterprise.example.com", - listOf(KnownIssues.ftlRateLimit) + listOf(KnownIssues.ftlRateLimit), ) ) }