Skip to content

Commit fe0d460

Browse files
authored
Update KtLint to 1.3.0 (#1184)
* Update KtLint to 1.3.0 * more * Remove since we have integrations in our project * More
1 parent 7dcb7f9 commit fe0d460

Some content is hidden

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

48 files changed

+1246
-958
lines changed

examples/trivial/.editorconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[*.{kt, kts}]
2+
indent_size = 2
3+
insert_final_newline = true
4+
max_line_length = 100
5+
ij_kotlin_allow_trailing_comma = true
6+
ij_kotlin_allow_trailing_comma_on_call_site = true

examples/trivial/BUILD

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
load("@rules_java//java:defs.bzl", "java_library")
2+
load("@rules_kotlin//kotlin:lint.bzl", "ktlint_config")
23

34
package(default_visibility = ["//visibility:public"])
45

@@ -13,3 +14,16 @@ java_library(
1314
"@maven//:org_opentest4j_opentest4j",
1415
],
1516
)
17+
18+
filegroup(
19+
name = "editorconfig",
20+
srcs = [".editorconfig"],
21+
)
22+
23+
ktlint_config(
24+
name = "ktlint_editorconfig",
25+
android_rules_enabled = False,
26+
editorconfig = "//:editorconfig",
27+
experimental_rules_enabled = False,
28+
visibility = ["//visibility:public"],
29+
)

examples/trivial/app/App.kt

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,28 @@ import com.expedia.graphql.TopLevelObject
55
import com.expedia.graphql.toSchema
66
import graphql.GraphQL
77

8-
data class Foo(val name: String, val age: Int)
8+
data class Foo(
9+
val name: String,
10+
val age: Int,
11+
)
912

1013
class Query {
11-
fun foo(bar: String?) = Foo("$bar!", 42)
14+
fun foo(bar: String?) = Foo("$bar!", 42)
1215
}
1316

1417
class MyApp {
15-
companion object {
16-
@JvmStatic
17-
fun main(args: Array<String>) {
18-
val schema = toSchema(queries = listOf(TopLevelObject(Query())), config = SchemaGeneratorConfig(listOf("app")))
19-
val graphql = GraphQL.newGraphQL(schema).build()
20-
val result = graphql.execute("""{ foo(bar: "baz") { name, age } }""").toSpecification()
18+
companion object {
19+
@JvmStatic
20+
fun main(args: Array<String>) {
21+
val schema =
22+
toSchema(
23+
queries = listOf(TopLevelObject(Query())),
24+
config = SchemaGeneratorConfig(listOf("app")),
25+
)
26+
val graphql = GraphQL.newGraphQL(schema).build()
27+
val result = graphql.execute("""{ foo(bar: "baz") { name, age } }""").toSpecification()
2128

22-
println(result)
23-
}
29+
println(result)
2430
}
31+
}
2532
}

examples/trivial/app/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ kt_jvm_library(
1313
ktlint_test(
1414
name = "lint_test",
1515
srcs = glob(["**/*.kt"]),
16+
config = "//:ktlint_editorconfig",
1617
)
1718

1819
ktlint_fix(
1920
name = "lint_fix",
2021
srcs = glob(["**/*.kt"]),
22+
config = "//:ktlint_editorconfig",
2123
)
2224

2325
java_binary(

src/main/kotlin/io/bazel/kotlin/builder/cmd/Build.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ object Build {
3434
.build()
3535
.work(),
3636
)
37-
}
38-
.run(::exitProcess)
37+
}.run(::exitProcess)
3938
}
4039
}

src/main/kotlin/io/bazel/kotlin/builder/cmd/MergeJdeps.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ object MergeJdeps {
2727
Worker
2828
.from(args.toList()) {
2929
start(DaggerJdepsMergerComponent.builder().build().work())
30-
}
31-
.run(::exitProcess)
30+
}.run(::exitProcess)
3231
}
3332
}

src/main/kotlin/io/bazel/kotlin/builder/tasks/CompileKotlin.kt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,18 @@ import io.bazel.worker.Work
2222
import io.bazel.worker.WorkerContext
2323
import javax.inject.Inject
2424

25-
class CompileKotlin @Inject constructor(private val builder: KotlinBuilder) : Work {
26-
override fun invoke(ctx: WorkerContext.TaskContext, args: Iterable<String>): Status {
27-
return if (builder.build(ctx, args.toList()) != 0) {
28-
Status.ERROR
29-
} else {
30-
Status.SUCCESS
31-
}
25+
class CompileKotlin
26+
@Inject
27+
constructor(
28+
private val builder: KotlinBuilder,
29+
) : Work {
30+
override fun invoke(
31+
ctx: WorkerContext.TaskContext,
32+
args: Iterable<String>,
33+
): Status =
34+
if (builder.build(ctx, args.toList()) != 0) {
35+
Status.ERROR
36+
} else {
37+
Status.SUCCESS
38+
}
3239
}
33-
}

0 commit comments

Comments
 (0)