You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
Thanks for submitting this issue, @hugoncosta! We didn't make ktlint compliance a requirement for our generated code and so I can understand why ktlint would complain if run on the generated code. We can definitely improve the style of generated code such that it does pass more style checks but we won't be able to appease every style checker, nor every variant of ktlint's rules. For that reason, we recommend users to run style-checking tools only on code they write and maintain by setting appropriate filters, includes, etc.
That said, the two specific issues highlighted above (missing trailing comma, unexpected space before type specifier) should be easy to fix. I'll work up a PR shortly.
Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
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
Expected behavior
In an ideal world, the code would follow the standard Ktlint rules
Current behavior
It doesn't follow it and it fails
And this is the generated code
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
The text was updated successfully, but these errors were encountered: