Skip to content

Commit 3d0534b

Browse files
authored
chore: clean up prospective ktlint warnings about missing copyright headers and single-expression bodies (#859)
1 parent fb4cca3 commit 3d0534b

File tree

42 files changed

+180
-60
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+180
-60
lines changed

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/auth/credentials/ImdsCredentialsProvider.kt

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,18 +137,16 @@ public class ImdsCredentialsProvider(
137137
}
138138
}
139139

140-
private suspend fun loadProfile(): String {
141-
return try {
142-
client.value.get(CREDENTIALS_BASE_PATH)
143-
} catch (ex: EC2MetadataError) {
144-
if (ex.statusCode == HttpStatusCode.NotFound.value) {
145-
coroutineContext.info<ImdsCredentialsProvider> {
146-
"Received 404 from IMDS when loading profile information. Hint: This instance may not have an " +
147-
"IAM role associated."
148-
}
140+
private suspend fun loadProfile() = try {
141+
client.value.get(CREDENTIALS_BASE_PATH)
142+
} catch (ex: EC2MetadataError) {
143+
if (ex.statusCode == HttpStatusCode.NotFound.value) {
144+
coroutineContext.info<ImdsCredentialsProvider> {
145+
"Received 404 from IMDS when loading profile information. Hint: This instance may not have an " +
146+
"IAM role associated."
149147
}
150-
throw ex
151148
}
149+
throw ex
152150
}
153151

154152
private suspend fun useCachedCredentials(ex: Exception): Credentials? = when {

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/auth/credentials/ProcessCredentialsProvider.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
15
package aws.sdk.kotlin.runtime.auth.credentials
26

37
import aws.smithy.kotlin.runtime.auth.awscredentials.Credentials

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/auth/credentials/StsWebIdentityCredentialsProvider.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ public class StsWebIdentityCredentialsProvider(
117117
}
118118

119119
// convenience function to resolve parameters for fromEnvironment()
120-
private inline fun <reified T> PlatformProvider.resolve(explicit: T?, setting: AwsSdkSetting<T>, name: String): T {
121-
return explicit ?: setting.resolve(this)
120+
private inline fun <reified T> PlatformProvider.resolve(explicit: T?, setting: AwsSdkSetting<T>, name: String): T =
121+
explicit
122+
?: setting.resolve(this)
122123
?: throw ProviderConfigurationException(
123124
"Required field `$name` could not be automatically inferred for StsWebIdentityCredentialsProvider. Either explicitly pass a value, set the environment variable `${setting.environmentVariable}`, or set the JVM system property `${setting.jvmProperty}`",
124125
)
125-
}

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/profile/AwsConfigLoader.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,12 @@ public suspend fun loadActiveAwsProfile(platform: PlatformProvider): AwsProfile
4242
*
4343
* @return A map of all profiles, which each are a map of key/value pairs.
4444
*/
45-
internal suspend fun loadAwsProfiles(platform: PlatformProvider, source: AwsConfigurationSource): Map<String, Map<String, String>> {
45+
internal suspend fun loadAwsProfiles(platform: PlatformProvider, source: AwsConfigurationSource) =
4646
// merged AWS configuration based on optional configuration and credential file contents
47-
return mergeProfiles(
47+
mergeProfiles(
4848
parse(FileType.CONFIGURATION, platform.readFileOrNull(source.configPath)?.decodeToString()),
4949
parse(FileType.CREDENTIAL, platform.readFileOrNull(source.credentialsPath)?.decodeToString()),
5050
)
51-
}
5251

5352
// Merge contents of profile maps
5453
internal fun mergeProfiles(vararg maps: ProfileMap) = buildMap<String, Map<String, String>> {

aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/ImdsCredentialsProviderTest.kt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -604,14 +604,12 @@ class ImdsCredentialsProviderTest {
604604

605605
// this engine just returns 500 errors
606606
val internalServerErrorEngine = object : HttpClientEngineBase("internalServerError") {
607-
override suspend fun roundTrip(context: ExecutionContext, request: HttpRequest): HttpCall {
608-
return HttpCall(
609-
HttpRequest(HttpMethod.GET, Url(Scheme.HTTP, Host.parse("test"), Scheme.HTTP.defaultPort, "/path/foo/bar"), Headers.Empty, HttpBody.Empty),
610-
HttpResponse(HttpStatusCode.InternalServerError, Headers.Empty, HttpBody.Empty),
611-
testClock.now(),
612-
testClock.now(),
613-
)
614-
}
607+
override suspend fun roundTrip(context: ExecutionContext, request: HttpRequest) = HttpCall(
608+
HttpRequest(HttpMethod.GET, Url(Scheme.HTTP, Host.parse("test"), Scheme.HTTP.defaultPort, "/path/foo/bar"), Headers.Empty, HttpBody.Empty),
609+
HttpResponse(HttpStatusCode.InternalServerError, Headers.Empty, HttpBody.Empty),
610+
testClock.now(),
611+
testClock.now(),
612+
)
615613
}
616614

617615
val client = ImdsClient {

aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/auth/credentials/ProcessCredentialsProviderTest.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
15
package aws.sdk.kotlin.runtime.auth.credentials
26

37
import aws.smithy.kotlin.runtime.auth.awscredentials.Credentials

aws-runtime/aws-config/common/test/aws/sdk/kotlin/runtime/config/AwsSdkSettingTest.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
15
package aws.sdk.kotlin.runtime.config
26

37
import aws.sdk.kotlin.runtime.config.retries.RetryMode
@@ -70,12 +74,11 @@ class AwsSdkSettingTest {
7074
assertEquals(expected, actual)
7175
}
7276

73-
private fun mockPlatform(env: Map<String, String>, jvmProps: Map<String, String>): PlatformEnvironProvider {
74-
return object : PlatformEnvironProvider {
77+
private fun mockPlatform(env: Map<String, String>, jvmProps: Map<String, String>) =
78+
object : PlatformEnvironProvider {
7579
override fun getAllEnvVars(): Map<String, String> = env
7680
override fun getenv(key: String): String? = env[key]
7781
override fun getAllProperties(): Map<String, String> = jvmProps
7882
override fun getProperty(key: String): String? = jvmProps[key]
7983
}
80-
}
8184
}

aws-runtime/aws-config/jvm/src/aws/sdk/kotlin/runtime/auth/credentials/SdkIOException.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
15
package aws.sdk.kotlin.runtime.auth.credentials
26

37
import java.io.IOException

aws-runtime/aws-config/jvm/src/aws/sdk/kotlin/runtime/auth/credentials/executeCommandJVM.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
15
package aws.sdk.kotlin.runtime.auth.credentials
26

37
import aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProviderException

aws-runtime/aws-config/jvm/test/aws/sdk/kotlin/runtime/config/AbstractAwsSdkClientFactoryTest.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,7 @@ private interface TestClient : SdkClient {
6666

6767
class Builder internal constructor() : AbstractSdkClientBuilder<Config, Config.Builder, TestClient>() {
6868
override val config: Config.Builder = Config.Builder()
69-
70-
override fun newClient(config: Config): TestClient {
71-
return DefaultTestClient(config)
72-
}
69+
override fun newClient(config: Config): TestClient = DefaultTestClient(config)
7370
}
7471

7572
class Config private constructor(builder: Config.Builder) : SdkClientConfig, AwsSdkClientConfig {

0 commit comments

Comments
 (0)