Skip to content

Commit edfa525

Browse files
committed
update .editorconfig and run ktlint
1 parent 9bb3310 commit edfa525

File tree

13 files changed

+93
-37
lines changed

13 files changed

+93
-37
lines changed

.editorconfig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
[*.{kt,kts}]
22
ktlint_code_style = intellij_idea
33

4+
# ktlint line length enforcement
5+
max_line_length = 120
6+
ktlint_ignore_back_ticked_identifier = true
7+
48
# ktlint rules to disable
59
ktlint_standard_no-wildcard-imports = disabled
610
ktlint_standard_filename = disabled
@@ -9,4 +13,4 @@ ktlint_standard_backing-property-naming = disabled
913
# enable trailing commas per JetBrains recommendation
1014
# (https://kotlinlang.org/docs/coding-conventions.html#trailing-commas)
1115
ij_kotlin_allow_trailing_comma_on_call_site = true
12-
ij_kotlin_allow_trailing_comma = true
16+
ij_kotlin_allow_trailing_comma = true

build-plugins/build-support/src/main/kotlin/aws/sdk/kotlin/gradle/dsl/Publish.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ fun Project.configurePublishing(repoName: String, githubOrganization: String = "
128128
onlyIf {
129129
isAvailableForPublication(project, publication).also {
130130
if (!it) {
131-
logger.warn("Skipping publication, project=${project.name}; publication=${publication.name}; group=${publication.groupId}")
131+
logger.warn(
132+
"Skipping publication, project=${project.name}; publication=${publication.name}; group=${publication.groupId}",
133+
)
132134
}
133135
}
134136
}

build-plugins/build-support/src/main/kotlin/aws/sdk/kotlin/gradle/plugins/artifactsizemetrics/AnalyzeArtifactSizeMetrics.kt

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ internal abstract class AnalyzeArtifactSizeMetrics : DefaultTask() {
4444
init {
4545
metricsFile.convention(project.layout.buildDirectory.file(OUTPUT_PATH + "artifact-size-metrics.csv"))
4646
analysisFile.convention(project.layout.buildDirectory.file(OUTPUT_PATH + "artifact-analysis.md"))
47-
hasSignificantChangeFile.convention(project.layout.buildDirectory.file(OUTPUT_PATH + "has-significant-change.txt"))
47+
hasSignificantChangeFile.convention(
48+
project.layout.buildDirectory.file(
49+
OUTPUT_PATH + "has-significant-change.txt",
50+
),
51+
)
4852
}
4953

5054
private val pluginConfig = project.rootProject.extensions.getByType(ArtifactSizeMetricsPluginConfig::class.java)
@@ -75,7 +79,8 @@ internal abstract class AnalyzeArtifactSizeMetrics : DefaultTask() {
7579
},
7680
) { latestReleaseMetrics ->
7781
file.writeText(
78-
latestReleaseMetrics.body?.decodeToString() ?: throw GradleException("Metrics from latest release are empty"),
82+
latestReleaseMetrics.body?.decodeToString()
83+
?: throw GradleException("Metrics from latest release are empty"),
7984
)
8085
}
8186
}
@@ -129,7 +134,8 @@ internal abstract class AnalyzeArtifactSizeMetrics : DefaultTask() {
129134
var artifactRequiresAttention = false
130135

131136
val ordinary = StringBuilder()
132-
.appendLine("<details>") // See: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections
137+
// See: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-collapsed-sections
138+
.appendLine("<details>")
133139
.appendLine("<summary>Changed in size</summary>")
134140
.appendLine()
135141
.append(tableHeader)
@@ -145,9 +151,21 @@ internal abstract class AnalyzeArtifactSizeMetrics : DefaultTask() {
145151
append("|")
146152
append(metric.key)
147153
append("|")
148-
if (metric.value.currentSize == 0L) append("(does not exist)") else append("%,d".format(metric.value.currentSize))
154+
if (metric.value.currentSize ==
155+
0L
156+
) {
157+
append("(does not exist)")
158+
} else {
159+
append("%,d".format(metric.value.currentSize))
160+
}
149161
append("|")
150-
if (metric.value.latestReleaseSize == 0L) append("(does not exist)") else append("%,d".format(metric.value.latestReleaseSize))
162+
if (metric.value.latestReleaseSize ==
163+
0L
164+
) {
165+
append("(does not exist)")
166+
} else {
167+
append("%,d".format(metric.value.latestReleaseSize))
168+
}
151169
append("|")
152170
append("%,d".format(metric.value.delta))
153171
append("|")
@@ -174,7 +192,8 @@ internal abstract class AnalyzeArtifactSizeMetrics : DefaultTask() {
174192
if (artifactOrdinaryChange) appendLine(ordinary)
175193
}
176194

177-
private fun ArtifactSizeMetric.requiresAttention() = this.percentage > pluginConfig.significantChangeThresholdPercentage || this.percentage.isNaN()
195+
private fun ArtifactSizeMetric.requiresAttention() =
196+
this.percentage > pluginConfig.significantChangeThresholdPercentage || this.percentage.isNaN()
178197

179198
private data class ArtifactSizeMetric(
180199
val currentSize: Long,

build-plugins/build-support/src/main/kotlin/aws/sdk/kotlin/gradle/plugins/artifactsizemetrics/ArtifactSizeMetricsPlugin.kt

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,25 @@ class ArtifactSizeMetricsPlugin : Plugin<Project> {
3131

3232
target.registerRootProjectArtifactSizeMetricsTask(tasks)
3333

34-
target.tasks.register<CollectDelegatedArtifactSizeMetrics>("collectDelegatedArtifactSizeMetrics") { group = TASK_GROUP }
34+
target.tasks.register<CollectDelegatedArtifactSizeMetrics>("collectDelegatedArtifactSizeMetrics") {
35+
group =
36+
TASK_GROUP
37+
}
3538
target.tasks.register<AnalyzeArtifactSizeMetrics>("analyzeArtifactSizeMetrics") { group = TASK_GROUP }
36-
target.tasks.register<PutArtifactSizeMetricsInCloudWatch>("putArtifactSizeMetricsInCloudWatch") { group = TASK_GROUP }
39+
target.tasks.register<PutArtifactSizeMetricsInCloudWatch>("putArtifactSizeMetricsInCloudWatch") {
40+
group =
41+
TASK_GROUP
42+
}
3743
target.tasks.register<SaveArtifactSizeMetrics>("saveArtifactSizeMetrics") { group = TASK_GROUP }
3844
}
3945
}
4046

41-
private fun Project.subprojectArtifactSizeMetricsTask(): TaskProvider<CollectArtifactSizeMetrics> = tasks.register<CollectArtifactSizeMetrics>("artifactSizeMetrics") {
42-
group = TASK_GROUP
43-
onlyIf { tasks.findByName("jvmJar") != null }
44-
dependsOn(tasks.withType<Jar>())
45-
}
47+
private fun Project.subprojectArtifactSizeMetricsTask(): TaskProvider<CollectArtifactSizeMetrics> =
48+
tasks.register<CollectArtifactSizeMetrics>("artifactSizeMetrics") {
49+
group = TASK_GROUP
50+
onlyIf { tasks.findByName("jvmJar") != null }
51+
dependsOn(tasks.withType<Jar>())
52+
}
4653

4754
private fun Project.registerRootProjectArtifactSizeMetricsTask(
4855
subProjects: List<TaskProvider<CollectArtifactSizeMetrics>>,

build-plugins/build-support/src/main/kotlin/aws/sdk/kotlin/gradle/plugins/artifactsizemetrics/CollectDelegatedArtifactSizeMetrics.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,13 @@ internal abstract class CollectDelegatedArtifactSizeMetrics : DefaultTask() {
3939
fun collect() {
4040
val pullRequestNumber = project.findProperty("pullRequest")?.toString()?.takeIf { it.isNotEmpty() }
4141
val releaseTag = project.findProperty("release")?.toString()?.takeIf { it.isNotEmpty() }
42-
val identifier = pullRequestNumber ?: releaseTag ?: throw AwsSdkGradleException("Please specify a pull request or release number")
42+
val identifier =
43+
pullRequestNumber ?: releaseTag
44+
?: throw AwsSdkGradleException("Please specify a pull request or release number")
4345

44-
val artifactSizeMetricsFileKeys = getFileKeys(identifier) ?: throw AwsSdkGradleException("Unable to list objects from artifact size metrics bucket")
46+
val artifactSizeMetricsFileKeys =
47+
getFileKeys(identifier)
48+
?: throw AwsSdkGradleException("Unable to list objects from artifact size metrics bucket")
4549
val artifactSizeMetricsFiles = getFiles(artifactSizeMetricsFileKeys)
4650
val combined = combine(artifactSizeMetricsFiles)
4751

build-plugins/build-support/src/main/kotlin/aws/sdk/kotlin/gradle/util/ProjectExt.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ public inline fun Project.verifyRootProject(lazyMessage: () -> Any) {
7070
* @return The property as a String
7171
*/
7272
fun Project.stringPropertyNotNull(property: String): String = findProperty(property)?.toString()?.also {
73-
check(it.isNotEmpty()) { "The $property property is set to empty \"-P$property=\" (no value set). Please specify a value." }
73+
check(it.isNotEmpty()) {
74+
"The $property property is set to empty \"-P$property=\" (no value set). Please specify a value."
75+
}
7476
} ?: throw AwsSdkGradleException("The $property property is not set. Please set a value: \"-P$property=YOUR_VALUE\"")
7577

7678
class AwsSdkGradleException(message: String) : GradleException(message)

build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureTargets.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ fun Project.configureKmpTargets() {
6060
pluginManager.withPlugin("kotlin-multiplatform") {
6161
val kmpExt = extensions.findByType(kmpExtensionClass)
6262
if (kmpExt == null) {
63-
logger.info("$name: skipping KMP configuration because multiplatform plugin has not been configured properly")
63+
logger.info(
64+
"$name: skipping KMP configuration because multiplatform plugin has not been configured properly",
65+
)
6466
return@withPlugin
6567
}
6668

build-plugins/smithy-build/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ gradlePlugin {
2727
val awsKotlinSmithyBuildPlugin by creating {
2828
id = "aws.sdk.kotlin.gradle.smithybuild"
2929
implementationClass = "aws.sdk.kotlin.gradle.codegen.SmithyBuildPlugin"
30-
description = "A plugin that wraps smithy gradle base plugin and provides a DSL for generating smithy-build.json dynamically"
30+
description =
31+
"A plugin that wraps smithy gradle base plugin and provides a DSL for generating smithy-build.json dynamically"
3132
}
3233
}
3334
}

build-plugins/smithy-build/src/main/kotlin/aws/sdk/kotlin/gradle/codegen/SmithyBuildExtension.kt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@ open class SmithyBuildExtension(private val project: Project) {
2525
* @param projectionName the name of the projection to get the output path for
2626
* @param pluginName the name of the plugin to get the output path for
2727
*/
28-
public fun getProjectionPath(projectionName: String, pluginName: String): Provider<Path> = SmithyUtils.getProjectionOutputDirProperty(project).map {
29-
// FIXME - smithy gradle plugin expects the input file to pass "isDirectory"
30-
// but that flag is only true IFF the path exists AND is a directory
31-
// see https://github.com/smithy-lang/smithy-gradle-plugin/issues/113
32-
it.asFile.mkdirs()
33-
SmithyUtils.getProjectionPluginPath(it.asFile, projectionName, pluginName)
34-
}
28+
public fun getProjectionPath(projectionName: String, pluginName: String): Provider<Path> =
29+
SmithyUtils.getProjectionOutputDirProperty(project).map {
30+
// FIXME - smithy gradle plugin expects the input file to pass "isDirectory"
31+
// but that flag is only true IFF the path exists AND is a directory
32+
// see https://github.com/smithy-lang/smithy-gradle-plugin/issues/113
33+
it.asFile.mkdirs()
34+
SmithyUtils.getProjectionPluginPath(it.asFile, projectionName, pluginName)
35+
}
3536
}
3637

3738
// smithy-kotlin specific extensions
@@ -42,12 +43,14 @@ open class SmithyBuildExtension(private val project: Project) {
4243
*
4344
* @param projectionName the name of the projection to use
4445
*/
45-
public fun SmithyBuildExtension.smithyKotlinProjectionPath(projectionName: String): Provider<Path> = getProjectionPath(projectionName, "kotlin-codegen")
46+
public fun SmithyBuildExtension.smithyKotlinProjectionPath(projectionName: String): Provider<Path> =
47+
getProjectionPath(projectionName, "kotlin-codegen")
4648

4749
/**
4850
* Get the default generated kotlin source directory for the `smithy-kotlin` plugin.
4951
* This is equivalent to `smithyBuild.getProjectionPath(projectionName, "kotlin-codegen")
5052
*
5153
* @param projectionName the name of the projection to use
5254
*/
53-
public fun SmithyBuildExtension.smithyKotlinProjectionSrcDir(projectionName: String): Provider<Path> = smithyKotlinProjectionPath(projectionName).map { it.resolve("src/main/kotlin") }
55+
public fun SmithyBuildExtension.smithyKotlinProjectionSrcDir(projectionName: String): Provider<Path> =
56+
smithyKotlinProjectionPath(projectionName).map { it.resolve("src/main/kotlin") }

build-plugins/smithy-build/src/main/kotlin/aws/sdk/kotlin/gradle/codegen/SmithyBuildPlugin.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ class SmithyBuildPlugin : Plugin<Project> {
7474
registerCodegenTasks()
7575
}
7676

77-
private fun Project.installExtension() = extensions.create(SMITHY_BUILD_EXTENSION_NAME, SmithyBuildExtension::class.java, project)
77+
private fun Project.installExtension() =
78+
extensions.create(SMITHY_BUILD_EXTENSION_NAME, SmithyBuildExtension::class.java, project)
7879

7980
private fun Project.registerCodegenTasks() {
8081
val generateSmithyBuild = tasks.register<GenerateSmithyBuild>(TASK_GENERATE_SMITHY_BUILD) {

0 commit comments

Comments
 (0)