-
Notifications
You must be signed in to change notification settings - Fork 54
Closed
Labels
feature-requestA feature should be added or improved.A feature should be added or improved.
Description
Describe the bug
Hello,
I am integrating the new DDB Mapper into my codebase and Ktlint (in its default configuration) is complaining that the generated code isn't correctly configured. I understand this might be outside your scope, and we should probably just not have Ktlint look at generated code, but it would still be a good to have
Regression Issue
- Select this option if this issue appears to be a regression.
Expected behavior
In an ideal world, the code would follow the standard Ktlint rules
Current behavior
It doesn't follow it and it fails
> Task :ktlintMainSourceSetCheck FAILED
/Volumes/workplace/NetworkValidatorDDBMapper/build/NetworkValidatorCommonLibrary/NetworkValidatorCommonLibrary-1.0/AL2_x86_64/DEV.STD.PTHREAD/build/private/gradle/generated/ksp/main/kotlin/com/amazon/networkvalidator/ddb/dynamodbmapper/generatedschemas/RuleSchema.kt:53:28 Missing trailing comma before ")"
/Volumes/workplace/NetworkValidatorDDBMapper/build/NetworkValidatorCommonLibrary/NetworkValidatorCommonLibrary-1.0/AL2_x86_64/DEV.STD.PTHREAD/build/private/gradle/generated/ksp/main/kotlin/com/amazon/networkvalidator/ddb/dynamodbmapper/generatedschemas/RuleSchema.kt:59:41 Missing trailing comma before ")"
/Volumes/workplace/NetworkValidatorDDBMapper/build/NetworkValidatorCommonLibrary/NetworkValidatorCommonLibrary-1.0/AL2_x86_64/DEV.STD.PTHREAD/build/private/gradle/generated/ksp/main/kotlin/com/amazon/networkvalidator/ddb/dynamodbmapper/generatedschemas/RuleSchema.kt:65:29 Missing trailing comma before ")"
/Volumes/workplace/NetworkValidatorDDBMapper/build/NetworkValidatorCommonLibrary/NetworkValidatorCommonLibrary-1.0/AL2_x86_64/DEV.STD.PTHREAD/build/private/gradle/generated/ksp/main/kotlin/com/amazon/networkvalidator/ddb/dynamodbmapper/generatedschemas/RuleSchema.kt:71:29 Missing trailing comma before ")"
/Volumes/workplace/NetworkValidatorDDBMapper/build/NetworkValidatorCommonLibrary/NetworkValidatorCommonLibrary-1.0/AL2_x86_64/DEV.STD.PTHREAD/build/private/gradle/generated/ksp/main/kotlin/com/amazon/networkvalidator/ddb/dynamodbmapper/generatedschemas/RuleSchema.kt:78:28 Unexpected spacing before ":"
And this is the generated code
// Code generated by dynamodb-mapper-annotation-processor. DO NOT EDIT!
package com.amazon.networkvalidator.ddb.dynamodbmapper.generatedschemas
import aws.sdk.kotlin.hll.dynamodbmapper.DynamoDbMapper
import aws.sdk.kotlin.hll.dynamodbmapper.items.AttributeDescriptor
import aws.sdk.kotlin.hll.dynamodbmapper.items.ItemConverter
import aws.sdk.kotlin.hll.dynamodbmapper.items.ItemSchema
import aws.sdk.kotlin.hll.dynamodbmapper.items.KeySpec
import aws.sdk.kotlin.hll.dynamodbmapper.items.SimpleItemConverter
import aws.sdk.kotlin.hll.dynamodbmapper.model.Table
import aws.sdk.kotlin.hll.dynamodbmapper.values.scalars.BooleanConverter
import aws.sdk.kotlin.hll.dynamodbmapper.values.scalars.EnumConverter
import aws.sdk.kotlin.hll.dynamodbmapper.values.scalars.StringConverter
import aws.smithy.kotlin.runtime.ExperimentalApi
import com.amazon.networkvalidator.ddb.Rule
import com.amazon.networkvalidator.ddb.RuleRuntime
/**
* A DSL-style builder for instances of [Rule]
*/
@ExperimentalApi
public class RuleBuilder {
public var ruleName: String? = null
public var ruleRuntime: RuleRuntime? = null
public var active: Boolean? = null
public var ioBound: Boolean? = null
public fun build(): Rule {
val ruleName = requireNotNull(ruleName) { "Missing value for ruleName" }
val ruleRuntime = requireNotNull(ruleRuntime) { "Missing value for ruleRuntime" }
val active = requireNotNull(active) { "Missing value for active" }
val ioBound = requireNotNull(ioBound) { "Missing value for ioBound" }
return Rule(
ruleName,
ruleRuntime,
active,
ioBound,
)
}
}
@ExperimentalApi
public object RuleConverter : ItemConverter<Rule> by SimpleItemConverter(
builderFactory = ::RuleBuilder,
build = RuleBuilder::build,
descriptors = arrayOf(
AttributeDescriptor(
"ruleName",
Rule::ruleName,
RuleBuilder::ruleName::set,
StringConverter
),
AttributeDescriptor(
"ruleRuntime",
Rule::ruleRuntime,
RuleBuilder::ruleRuntime::set,
EnumConverter<RuleRuntime>()
),
AttributeDescriptor(
"active",
Rule::active,
RuleBuilder::active::set,
BooleanConverter
),
AttributeDescriptor(
"ioBound",
Rule::ioBound,
RuleBuilder::ioBound::set,
BooleanConverter
),
),
)
@ExperimentalApi
public object RuleSchema : ItemSchema.PartitionKey<Rule, String> {
override val converter : RuleConverter = RuleConverter
override val partitionKey: KeySpec<String> = aws.sdk.kotlin.hll.dynamodbmapper.items.KeySpec.String("ruleName")
}
/**
* Returns a reference to a table named [name] containing items representing [Rule]
*/
@ExperimentalApi
public fun DynamoDbMapper.getRuleTable(name: String): Table.PartitionKey<Rule, String> = getTable(name, RuleSchema)
Steps to Reproduce
This happens in any of the generated schemas, as long as you run :ktlintMainSourceSetCheck on top of it. We're using Ktlint 1.2.1 and all the default rules.
Possible Solution
Add the trailing commas and remove the unexpected spacing? :)
Context
No response
AWS SDK for Kotlin version
1.4.14-beta
Platform (JVM/JS/Native)
Jvm
Operating system and version
macOS Sequioa 15.3
Metadata
Metadata
Assignees
Labels
feature-requestA feature should be added or improved.A feature should be added or improved.