diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..9813448 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,5 @@ +[*.{kt,kts}] +indent_size = 4 +continuation_indent_size = 4 +insert_final_newline = true +max_line_length = 120 diff --git a/build.gradle.kts b/build.gradle.kts index da4784f..324ec17 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,6 +2,7 @@ plugins { alias(libs.plugins.kotlin.jvm) alias(libs.plugins.ktor) + alias(libs.plugins.spotless) } group = "com.es" @@ -33,3 +34,14 @@ dependencies { testImplementation(libs.ktor.server.test.host) testImplementation(libs.kotlin.test.junit) } + +spotless { + kotlin { + ktlint("1.2.1") + target("**/*.kt") + suppressLintsFor { + step = "ktlint" + shortCode = "standard:no-wildcard-imports" + } + } +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 150258c..6d5796a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,6 +3,7 @@ kotlin-version = "2.1.20" ktor-version = "3.1.1" logback-version = "1.4.14" jackson-version = "2.15.0" +spotless-version = "7.0.3" [libraries] ktor-server-content-negotiation = { module = "io.ktor:ktor-server-content-negotiation", version.ref = "ktor-version" } @@ -22,3 +23,4 @@ jackson-dataformat-xml = { module = "com.fasterxml.jackson.dataformat:jackson-da [plugins] kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin-version" } ktor = { id = "io.ktor.plugin", version.ref = "ktor-version" } +spotless = { id = "com.diffplug.spotless", version.ref = "spotless-version" } diff --git a/src/main/kotlin/model/BGGPropertyValue.kt b/src/main/kotlin/model/BGGPropertyValue.kt index 0338fa8..36220ca 100644 --- a/src/main/kotlin/model/BGGPropertyValue.kt +++ b/src/main/kotlin/model/BGGPropertyValue.kt @@ -6,5 +6,5 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty data class BGGPropertyValue( @JacksonXmlProperty(isAttribute = true) @JsonProperty("value") - val value: String? = null + val value: String? = null, ) diff --git a/src/main/kotlin/model/detail/BGGGameDetailItem.kt b/src/main/kotlin/model/detail/BGGGameDetailItem.kt index 0160402..5716e74 100644 --- a/src/main/kotlin/model/detail/BGGGameDetailItem.kt +++ b/src/main/kotlin/model/detail/BGGGameDetailItem.kt @@ -1,7 +1,7 @@ package com.es.model.detail -import com.es.model.search.BGGGameItemName import com.es.model.BGGPropertyValue +import com.es.model.search.BGGGameItemName import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper @@ -12,63 +12,50 @@ data class BGGGameDetailItem( @JacksonXmlProperty(isAttribute = true) @JsonProperty("id") val id: String, - @JacksonXmlProperty(isAttribute = true) @JsonProperty("type") val type: String, - @JacksonXmlProperty(localName = "thumbnail") @JsonProperty("thumbnail") val thumbnail: String? = null, - @JacksonXmlProperty(localName = "image") @JsonProperty("image") val image: String? = null, - @JacksonXmlElementWrapper(useWrapping = false) @JacksonXmlProperty(localName = "name") @JsonProperty("names") val names: List? = null, - @JacksonXmlProperty(localName = "description") @JsonProperty("description") val description: String? = null, - @JacksonXmlElementWrapper(useWrapping = false) @JacksonXmlProperty(localName = "yearpublished") @JsonProperty("yearpublished") val yearPublished: BGGPropertyValue? = null, - @JacksonXmlElementWrapper(useWrapping = false) @JacksonXmlProperty(localName = "minplayers") @JsonProperty("minplayers") val minPlayers: BGGPropertyValue? = null, - @JacksonXmlElementWrapper(useWrapping = false) @JacksonXmlProperty(localName = "maxplayers") @JsonProperty("maxplayers") val maxPlayers: BGGPropertyValue? = null, - @JacksonXmlElementWrapper(useWrapping = false) @JacksonXmlProperty(localName = "playingtime") @JsonProperty("playingtime") val playingTime: BGGPropertyValue? = null, - @JacksonXmlElementWrapper(useWrapping = false) @JacksonXmlProperty(localName = "minplaytime") @JsonProperty("minplaytime") val minPlayTime: BGGPropertyValue? = null, - @JacksonXmlElementWrapper(useWrapping = false) @JacksonXmlProperty(localName = "maxplaytime") @JsonProperty("maxplaytime") val maxPlayTime: BGGPropertyValue? = null, - @JacksonXmlElementWrapper(useWrapping = false) @JacksonXmlProperty(localName = "minage") @JsonProperty("minage") val minAge: BGGPropertyValue? = null, - @JacksonXmlElementWrapper(useWrapping = false) @JacksonXmlProperty(localName = "link") @JsonProperty("links") diff --git a/src/main/kotlin/model/detail/BGGGameDetailLink.kt b/src/main/kotlin/model/detail/BGGGameDetailLink.kt index 8c40981..76582b8 100644 --- a/src/main/kotlin/model/detail/BGGGameDetailLink.kt +++ b/src/main/kotlin/model/detail/BGGGameDetailLink.kt @@ -9,12 +9,10 @@ data class BGGGameDetailLink( @JacksonXmlProperty(isAttribute = true) @JsonProperty("type") val type: String? = null, - @JacksonXmlProperty(isAttribute = true) @JsonProperty("id") val id: String? = null, - @JacksonXmlProperty(isAttribute = true) @JsonProperty("value") - val value: String? = null + val value: String? = null, ) diff --git a/src/main/kotlin/model/search/BGGGameItem.kt b/src/main/kotlin/model/search/BGGGameItem.kt index 92dc442..86e827b 100644 --- a/src/main/kotlin/model/search/BGGGameItem.kt +++ b/src/main/kotlin/model/search/BGGGameItem.kt @@ -3,22 +3,20 @@ package com.es.model.search import com.es.model.BGGPropertyValue import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty @JsonIgnoreProperties(ignoreUnknown = true) data class BGGGameItem( @JacksonXmlProperty(isAttribute = true) @JsonProperty("id") val id: String, - @JacksonXmlElementWrapper(useWrapping = false) @JacksonXmlProperty(localName = "name") @JsonProperty("name") val name: BGGGameItemName? = null, - @JacksonXmlElementWrapper(useWrapping = false) @JacksonXmlProperty(localName = "yearpublished") @JsonProperty("yearpublished") - val yearPublished: BGGPropertyValue? = null + val yearPublished: BGGPropertyValue? = null, ) diff --git a/src/main/kotlin/model/search/BGGGameItemName.kt b/src/main/kotlin/model/search/BGGGameItemName.kt index 6810b1e..9349f47 100644 --- a/src/main/kotlin/model/search/BGGGameItemName.kt +++ b/src/main/kotlin/model/search/BGGGameItemName.kt @@ -9,8 +9,7 @@ data class BGGGameItemName( @JacksonXmlProperty(isAttribute = true) @JsonProperty("type") val type: String? = null, - @JacksonXmlProperty(isAttribute = true) @JsonProperty("value") - val value: String? = null + val value: String? = null, )