Skip to content

Commit f9bb8c0

Browse files
authored
Fix ktlint (#178)
- bump up ktlint plugin version which supports kotlin 2.2.0 - disable some rules and follow two rules (enum wrapping, max line)
1 parent a592220 commit f9bb8c0

File tree

8 files changed

+29
-15
lines changed

8 files changed

+29
-15
lines changed

.editorconfig

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,17 @@
22
root = true
33

44
[*.{kt, kts}]
5-
disabled_rules = import-ordering, indent
6-
# disable indent rule until https://github.com/pinterest/ktlint/issues/764 is fixed.
5+
disabled_rules = import-ordering
6+
ktlint_standard_trailing-comma-on-call-site = disabled
7+
ktlint_standard_trailing-comma-on-declaration-site = disabled
8+
ktlint_standard_wrapping = disabled
9+
ktlint_standard_no-blank-line-in-list = disabled
10+
ktlint_standard_function-signature = disabled
11+
ktlint_standard_class-signature = disabled
12+
ktlint_standard_multiline-expression-wrapping = disabled
13+
ktlint_standard_chain-method-continuation = disabled
14+
ktlint_standard_binary-expression-wrapping = disabled
15+
ktlint_standard_argument-list-wrapping = disabled
716

817
[*]
918
# [encoding-utf8]

guide-projects/plus-sql-java-kotlin-guide/src/main/java/com/navercorp/spring/data/jdbc/plus/sql/guide/board/sql/BoardSql.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import com.navercorp.spring.data.jdbc.plus.sql.support.SqlGeneratorSupport
2626
* @author Myeonghyeon Lee
2727
*/
2828
class BoardSql : SqlGeneratorSupport() {
29-
3029
fun selectGraphById(): String = """
3130
SELECT ${sql.aggregateColumns(Board::class.java)}
3231

guide-projects/plus-sql-kotlin-guide/build.gradle.kts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
22

33
plugins {
44
id("spring.jdbc.plus.spring-bom-conventions")
5-
id("org.jlleitschuh.gradle.ktlint") version "10.2.0"
5+
id("org.jlleitschuh.gradle.ktlint") version "13.0.0"
66
kotlin("jvm")
77
kotlin("plugin.spring") version "1.9.20"
88
}
@@ -12,6 +12,10 @@ tasks.withType<KotlinCompile> {
1212
kotlinOptions.javaParameters = true
1313
}
1414

15+
ktlint {
16+
outputToConsole.set(true)
17+
}
18+
1519
dependencies {
1620
implementation("org.springframework.boot:spring-boot-starter-web")
1721
implementation(project(":spring-boot-starter-data-jdbc-plus-sql"))

guide-projects/plus-sql-kotlin-guide/src/main/kotlin/com/navercorp/spring/data/jdbc/plus/sql/guide/Application.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import org.springframework.boot.runApplication
2626
*/
2727
@SpringBootApplication
2828
class Application {
29-
3029
fun main(args: Array<String>) {
3130
runApplication<Application>(*args)
3231
}

guide-projects/plus-sql-kotlin-guide/src/main/kotlin/com/navercorp/spring/data/jdbc/plus/sql/guide/board/sql/BoardSql.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import com.navercorp.spring.data.jdbc.plus.sql.support.SqlGeneratorSupport
2626
* @author Myeonghyeon Lee
2727
*/
2828
class BoardSql : SqlGeneratorSupport() {
29-
3029
fun selectGraphById(): String = """
3130
SELECT ${sql.aggregateColumns(Board::class.java)}
3231

guide-projects/plus-sql-kotlin-guide/src/main/kotlin/com/navercorp/spring/data/jdbc/plus/sql/guide/order/Order.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ data class Order(
3333
)
3434

3535
enum class OrderStatus {
36-
PLACE, COMPLETED
36+
PLACE,
37+
COMPLETED
3738
}

guide-projects/plus-sql-kotlin-guide/src/main/kotlin/com/navercorp/spring/data/jdbc/plus/sql/guide/order/OrderCriteria.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ data class OrderCriteria(
2828
)
2929

3030
enum class OrderSort {
31-
ID, PRICE
31+
ID,
32+
PRICE
3233
}

guide-projects/plus-sql-kotlin-guide/src/test/kotlin/com/navercorp/spring/data/jdbc/plus/sql/guide/board/BoardRepositoryTest.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import org.springframework.beans.factory.annotation.Autowired
2424
import org.springframework.boot.test.context.SpringBootTest
2525
import org.springframework.test.context.ActiveProfiles
2626
import org.springframework.transaction.annotation.Transactional
27-
import java.util.Comparator
2827
import java.util.stream.Collectors
2928

3029
/**
@@ -76,9 +75,12 @@ class BoardRepositoryTest {
7675
)
7776
),
7877
configMap = mapOf(
79-
"board1 post1 config-key" to Config(configKey = "board1 post1 config-key", configValue = "board1 post1 config-value"),
80-
"board1 post1 config-key2" to Config(configKey = "board1 post1 config-key2", configValue = "board1 post1 config-value2"),
81-
"board1 post1 config-key3" to Config(configKey = "board1 post1 config-key3", configValue = "board1 post1 config-value3")
78+
"board1 post1 config-key" to
79+
Config(configKey = "board1 post1 config-key", configValue = "board1 post1 config-value"),
80+
"board1 post1 config-key2" to
81+
Config(configKey = "board1 post1 config-key2", configValue = "board1 post1 config-value2"),
82+
"board1 post1 config-key3" to
83+
Config(configKey = "board1 post1 config-key3", configValue = "board1 post1 config-value3")
8284
),
8385
audit = Audit(
8486
name = "naver1",
@@ -435,7 +437,7 @@ class BoardRepositoryTest {
435437
}
436438
val actualLabels: List<Label> =
437439
actual.labels.stream().sorted(Comparator.comparingLong { obj: Label -> obj.id!! }).collect(Collectors.toList())
438-
val boardLabels: List<Label> = actual.labels.stream().sorted(Comparator.comparingLong { obj: Label -> obj.id!! }).collect(Collectors.toList())
440+
val boardLabels: List<Label> = actual.labels.sortedBy { it.id }
439441
assertLabelsEquals(actualLabels, boardLabels)
440442
val actualPosts: List<Post> = actual.posts
441443
val boardPosts: List<Post> = target.posts
@@ -482,8 +484,8 @@ class BoardRepositoryTest {
482484
assertThat(actualPost.audit!!.secret!!.secret).isEqualTo(targetPost.audit!!.secret!!.secret)
483485
}
484486
}
485-
val actualTags: List<Tag> = actualPost.tags.stream().sorted(Comparator.comparingLong { obj: Tag -> obj.id!! }).collect(Collectors.toList())
486-
val postTags: List<Tag> = targetPost.tags.stream().sorted(Comparator.comparingLong { obj: Tag -> obj.id!! }).collect(Collectors.toList())
487+
val actualTags: List<Tag> = actualPost.tags.sortedBy { it.id }
488+
val postTags: List<Tag> = targetPost.tags.sortedBy { it.id }
487489
assertThat(actualTags.size).isEqualTo(postTags.size)
488490
for (i in actualTags.indices) {
489491
assertThat(actualTags[i].id).isEqualTo(postTags[i].id)

0 commit comments

Comments
 (0)