Skip to content

Commit 2b760b2

Browse files
authored
chore: lint _all_ the things (#847)
1 parent f1f6447 commit 2b760b2

File tree

60 files changed

+315
-254
lines changed

Some content is hidden

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

60 files changed

+315
-254
lines changed

build.gradle.kts

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ allprojects {
5050
"separateInheritedMembers" : true,
5151
"templatesDir": "${rootProject.file("docs/dokka-presets/templates")}"
5252
}
53-
"""
53+
""",
5454
)
5555
pluginsMapConfiguration.set(pluginConfigMap)
5656
}
@@ -142,9 +142,9 @@ dependencies {
142142
}
143143

144144
val lintPaths = listOf(
145-
"smithy-kotlin-codegen/src/**/*.kt",
146-
"runtime/**/*.kt",
147-
"tests/**/jvm/**/*.kt",
145+
"**/*.{kt,kts}",
146+
"!**/generated-src/**",
147+
"!**/smithyprojections/**",
148148
)
149149

150150
tasks.register<JavaExec>("ktlint") {
@@ -153,6 +153,7 @@ tasks.register<JavaExec>("ktlint") {
153153
classpath = configurations.getByName("ktlint")
154154
main = "com.pinterest.ktlint.Main"
155155
args = lintPaths
156+
jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
156157
}
157158

158159
tasks.register<JavaExec>("ktlintFormat") {
@@ -161,28 +162,31 @@ tasks.register<JavaExec>("ktlintFormat") {
161162
classpath = configurations.getByName("ktlint")
162163
main = "com.pinterest.ktlint.Main"
163164
args = listOf("-F") + lintPaths
165+
jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
164166
}
165167

166168
apiValidation {
167169
nonPublicMarkers.add("aws.smithy.kotlin.runtime.InternalApi")
168170

169-
ignoredProjects.addAll(setOf(
170-
"dokka-smithy",
171-
"ktlint-rules",
172-
"aws-signing-tests",
173-
"test-suite",
174-
"http-test",
175-
"smithy-test",
176-
"testing",
177-
"smithy-kotlin-codegen",
178-
"smithy-kotlin-codegen-testutils",
179-
"aws-signing-benchmarks",
180-
"channel-benchmarks",
181-
"http-benchmarks",
182-
"serde-benchmarks",
183-
"serde-benchmarks-codegen",
184-
"paginator-tests",
185-
"waiter-tests",
186-
"compile"
187-
))
171+
ignoredProjects.addAll(
172+
setOf(
173+
"dokka-smithy",
174+
"ktlint-rules",
175+
"aws-signing-tests",
176+
"test-suite",
177+
"http-test",
178+
"smithy-test",
179+
"testing",
180+
"smithy-kotlin-codegen",
181+
"smithy-kotlin-codegen-testutils",
182+
"aws-signing-benchmarks",
183+
"channel-benchmarks",
184+
"http-benchmarks",
185+
"serde-benchmarks",
186+
"serde-benchmarks-codegen",
187+
"paginator-tests",
188+
"waiter-tests",
189+
"compile",
190+
),
191+
)
188192
}

codegen/smithy-kotlin-codegen-testutils/src/main/kotlin/software/amazon/smithy/kotlin/codegen/test/ModelTestUtils.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ object TestModelDefault {
4545
// attempt to replicate transforms that happen in CodegenVisitor such that tests
4646
// more closely reflect reality
4747
private fun Model.applyKotlinCodegenTransforms(serviceShapeId: String?): Model {
48-
val serviceId = if (serviceShapeId != null) ShapeId.from(serviceShapeId) else {
48+
val serviceId = serviceShapeId?.let(ShapeId::from) ?: run {
4949
// try to autodiscover the service so that tests "Just Work" (TM) without having to do anything
5050
val services = this.shapes<ServiceShape>()
5151
check(services.size <= 1) { "multiple services discovered in model; auto inference of service shape impossible for test. Fix by passing the service shape explicitly" }
@@ -221,7 +221,7 @@ fun String.generateTestModel(
221221
// Specifies AWS protocols that can be set on test models.
222222
enum class AwsProtocolModelDeclaration(val annotation: String, val import: String) {
223223
REST_JSON("@restJson1", "aws.protocols#restJson1"),
224-
AWS_JSON_1_1("@awsJson1_1", "aws.protocols#awsJson1_1")
224+
AWS_JSON_1_1("@awsJson1_1", "aws.protocols#awsJson1_1"),
225225
}
226226

227227
// Generates the model header which by default conforms to the conventions defined for test models.
@@ -259,5 +259,5 @@ fun String.prependNamespaceAndService(
259259
260260
261261
""".trimIndent() + this.trimIndent()
262-
)
262+
)
263263
}

codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/CodegenVisitor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,4 @@ private fun ProtocolGenerator.generateAuthSchemeProvider(ctx: ProtocolGenerator.
216216
authSchemeProviderGenerator().render(ctx)
217217
authSchemeProviderAdapterGenerator().render(ctx)
218218
}
219-
}
219+
}

codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/core/RuntimeTypes.kt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ object RuntimeTypes {
135135
}
136136
}
137137

138-
139138
object Hashing : RuntimeTypePackage(KotlinDependency.CORE, "hashing") {
140139
val Sha256 = symbol("Sha256")
141140
}
@@ -258,7 +257,7 @@ object RuntimeTypes {
258257
}
259258
}
260259

261-
object Identity : RuntimeTypePackage(KotlinDependency.IDENTITY_API){
260+
object Identity : RuntimeTypePackage(KotlinDependency.IDENTITY_API) {
262261
val AuthSchemeId = symbol("AuthSchemeId", "auth")
263262
val AuthSchemeProvider = symbol("AuthSchemeProvider", "auth")
264263
val AuthSchemeOption = symbol("AuthSchemeOption", "auth")
@@ -286,15 +285,15 @@ object RuntimeTypes {
286285
}
287286
}
288287

289-
object HttpAuth: RuntimeTypePackage(KotlinDependency.HTTP_AUTH) {
290-
val AnonymousAuthScheme = symbol("AnonymousAuthScheme")
288+
object HttpAuth : RuntimeTypePackage(KotlinDependency.HTTP_AUTH) {
289+
val AnonymousAuthScheme = symbol("AnonymousAuthScheme")
291290
val AnonymousIdentity = symbol("AnonymousIdentity")
292291
val AnonymousIdentityProvider = symbol("AnonymousIdentityProvider")
293292
val HttpAuthConfig = symbol("HttpAuthConfig")
294293
val HttpAuthScheme = symbol("HttpAuthScheme")
295294
}
296295

297-
object HttpAuthAws : RuntimeTypePackage(KotlinDependency.HTTP_AUTH_AWS){
296+
object HttpAuthAws : RuntimeTypePackage(KotlinDependency.HTTP_AUTH_AWS) {
298297
val AwsHttpSigner = symbol("AwsHttpSigner")
299298
val SigV4AuthScheme = symbol("SigV4AuthScheme")
300299
val sigv4 = symbol("sigv4")
@@ -317,7 +316,7 @@ object RuntimeTypes {
317316
val coroutineContext = "kotlin.coroutines.coroutineContext".toSymbol()
318317
}
319318

320-
object KotlinxCoroutines{
319+
object KotlinxCoroutines {
321320

322321
val CompletableDeferred = "kotlinx.coroutines.CompletableDeferred".toSymbol()
323322
val job = "kotlinx.coroutines.job".toSymbol()
@@ -335,24 +334,24 @@ object RuntimeTypes {
335334
}
336335
}
337336

338-
object AwsProtocolCore: RuntimeTypePackage(KotlinDependency.AWS_PROTOCOL_CORE) {
337+
object AwsProtocolCore : RuntimeTypePackage(KotlinDependency.AWS_PROTOCOL_CORE) {
339338
val withPayload = symbol("withPayload")
340339
val setAseErrorMetadata = symbol("setAseErrorMetadata")
341340
val AwsQueryCompatibleErrorDetails = symbol("AwsQueryCompatibleErrorDetails")
342341
val setAwsQueryCompatibleErrorMetadata = symbol("setAwsQueryCompatibleErrorMetadata")
343342
val XAmznQueryErrorHeader = symbol("X_AMZN_QUERY_ERROR_HEADER")
344343
}
345344

346-
object AwsJsonProtocols: RuntimeTypePackage(KotlinDependency.AWS_JSON_PROTOCOLS) {
345+
object AwsJsonProtocols : RuntimeTypePackage(KotlinDependency.AWS_JSON_PROTOCOLS) {
347346
val AwsJsonProtocol = symbol("AwsJsonProtocol")
348347
val RestJsonErrorDeserializer = symbol("RestJsonErrorDeserializer")
349348
}
350-
object AwsXmlProtocols: RuntimeTypePackage(KotlinDependency.AWS_XML_PROTOCOLS) {
349+
object AwsXmlProtocols : RuntimeTypePackage(KotlinDependency.AWS_XML_PROTOCOLS) {
351350
val parseRestXmlErrorResponse = symbol("parseRestXmlErrorResponse")
352351
val parseEc2QueryErrorResponse = symbol("parseEc2QueryErrorResponse")
353352
}
354353

355-
object AwsEventStream: RuntimeTypePackage(KotlinDependency.AWS_EVENT_STREAM) {
354+
object AwsEventStream : RuntimeTypePackage(KotlinDependency.AWS_EVENT_STREAM) {
356355
val HeaderValue = symbol("HeaderValue")
357356
val Message = symbol("Message")
358357
val MessageType = symbol("MessageType")

codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/integration/AuthSchemeHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ interface AuthSchemeHandler {
5656
* @return the expression to render
5757
*/
5858
fun instantiateAuthSchemeExpr(ctx: ProtocolGenerator.GenerationContext, writer: KotlinWriter)
59-
}
59+
}

codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/integration/KotlinIntegration.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ interface KotlinIntegration {
148148
resolved: List<ProtocolMiddleware>,
149149
): List<ProtocolMiddleware> = resolved
150150

151-
152151
/**
153152
* Get a list of auth scheme handlers this integration is responsible for
154153
*/
@@ -162,4 +161,3 @@ interface KotlinIntegration {
162161
*/
163162
fun renderBindEndpointBuiltins(ctx: ProtocolGenerator.GenerationContext, rules: EndpointRuleSet, writer: KotlinWriter) {}
164163
}
165-

codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/model/knowledge/AuthIndex.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class AuthIndex {
3232
.flatMap { it.authSchemes(ctx) }
3333
.associateBy(AuthSchemeHandler::authSchemeId)
3434

35-
3635
/**
3736
* Get the prioritized list of effective [AuthSchemeHandler] for an operation.
3837
*
@@ -48,7 +47,7 @@ class AuthIndex {
4847
val opEffectiveAuthSchemes = serviceIndex.getEffectiveAuthSchemes(ctx.service, op)
4948
return if (op.hasTrait<OptionalAuthTrait>() || opEffectiveAuthSchemes.isEmpty()) {
5049
listOf(AnonymousAuthSchemeHandler())
51-
}else {
50+
} else {
5251
// return handlers in same order as the priority list dictated by `auth([])` trait
5352
opEffectiveAuthSchemes.mapNotNull {
5453
allAuthHandlers[it.key]
@@ -96,7 +95,7 @@ class AuthIndex {
9695
// reconcile anonymous auth
9796
val topDownIndex = TopDownIndex.of(ctx.model)
9897
val addAnonymousHandler = topDownIndex.getContainedOperations(ctx.service)
99-
.any { op ->
98+
.any { op ->
10099
val opEffectiveAuthSchemes = serviceIndex.getEffectiveAuthSchemes(ctx.service, op)
101100
op.hasTrait<OptionalAuthTrait>() || opEffectiveAuthSchemes.isEmpty()
102101
}
@@ -121,5 +120,4 @@ class AuthIndex {
121120

122121
return operationsWithOverrides.toSet()
123122
}
124-
125-
}
123+
}

codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/model/knowledge/EndpointParameterIndex.kt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,14 @@ import software.amazon.smithy.kotlin.codegen.utils.getOrNull
1010
import software.amazon.smithy.model.Model
1111
import software.amazon.smithy.model.knowledge.KnowledgeIndex
1212
import software.amazon.smithy.model.knowledge.OperationIndex
13-
import software.amazon.smithy.model.shapes.MemberShape
1413
import software.amazon.smithy.model.shapes.OperationShape
1514
import software.amazon.smithy.rulesengine.traits.ContextParamTrait
1615
import software.amazon.smithy.rulesengine.traits.StaticContextParamsTrait
1716

18-
1917
/**
2018
* Provides endpoint parameter binding knowledge index
2119
*/
22-
class EndpointParameterIndex private constructor(model: Model): KnowledgeIndex {
20+
class EndpointParameterIndex private constructor(model: Model) : KnowledgeIndex {
2321
private val opIndex = OperationIndex.of(model)
2422

2523
/**
@@ -36,16 +34,15 @@ class EndpointParameterIndex private constructor(model: Model): KnowledgeIndex {
3634
* @param op the operation shape to get context params for
3735
* @return map of parameter name to input member shape
3836
*/
39-
fun inputContextParams(op: OperationShape): Map<String, MemberShape> {
37+
fun inputContextParams(op: OperationShape) =
4038
// maps endpoint parameter name -> input member shape
41-
return buildMap {
39+
buildMap {
4240
opIndex.getInput(op).getOrNull()?.members()?.forEach { member ->
4341
member.getTrait<ContextParamTrait>()?.let { trait ->
4442
put(trait.name, member)
4543
}
4644
}
4745
}
48-
}
4946

5047
/**
5148
* Check if there are any context parameters bound to an operation
@@ -59,5 +56,4 @@ class EndpointParameterIndex private constructor(model: Model): KnowledgeIndex {
5956
companion object {
6057
fun of(model: Model): EndpointParameterIndex = EndpointParameterIndex(model)
6158
}
62-
63-
}
59+
}

codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/ServiceClientConfigGenerator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,4 @@ class ServiceClientConfigGenerator(
135135
}
136136
}
137137

138-
private fun Collection<ConfigProperty>.byName(): Map<String, ConfigProperty> = associateBy(ConfigProperty::propertyName)
138+
private fun Collection<ConfigProperty>.byName(): Map<String, ConfigProperty> = associateBy(ConfigProperty::propertyName)

codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/ShapeValueGenerator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ class ShapeValueGenerator(
265265
// the value is in seconds and CAN be fractional
266266
if (node.isFloatingPointNumber) {
267267
val value = node.value as Double
268-
val ms = round(value*1e3).toLong()
268+
val ms = round(value * 1e3).toLong()
269269
writer.writeInline("Instant.#T(#L)", RuntimeTypes.Core.fromEpochMilliseconds, ms)
270270
} else {
271271
writer.writeInline("Instant.fromEpochSeconds(#L, 0)", node.value)

0 commit comments

Comments
 (0)