Skip to content

Commit

Permalink
Update KtLint to 1.3.0 (#1184)
Browse files Browse the repository at this point in the history
* Update KtLint to 1.3.0

* more

* Remove since we have integrations in our project

* More
  • Loading branch information
Bencodes committed Jun 28, 2024
1 parent 7dcb7f9 commit fe0d460
Show file tree
Hide file tree
Showing 48 changed files with 1,246 additions and 958 deletions.
6 changes: 6 additions & 0 deletions examples/trivial/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[*.{kt, kts}]
indent_size = 2
insert_final_newline = true
max_line_length = 100
ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true
14 changes: 14 additions & 0 deletions examples/trivial/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@rules_java//java:defs.bzl", "java_library")
load("@rules_kotlin//kotlin:lint.bzl", "ktlint_config")

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

Expand All @@ -13,3 +14,16 @@ java_library(
"@maven//:org_opentest4j_opentest4j",
],
)

filegroup(
name = "editorconfig",
srcs = [".editorconfig"],
)

ktlint_config(
name = "ktlint_editorconfig",
android_rules_enabled = False,
editorconfig = "//:editorconfig",
experimental_rules_enabled = False,
visibility = ["//visibility:public"],
)
27 changes: 17 additions & 10 deletions examples/trivial/app/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,28 @@ import com.expedia.graphql.TopLevelObject
import com.expedia.graphql.toSchema
import graphql.GraphQL

data class Foo(val name: String, val age: Int)
data class Foo(
val name: String,
val age: Int,
)

class Query {
fun foo(bar: String?) = Foo("$bar!", 42)
fun foo(bar: String?) = Foo("$bar!", 42)
}

class MyApp {
companion object {
@JvmStatic
fun main(args: Array<String>) {
val schema = toSchema(queries = listOf(TopLevelObject(Query())), config = SchemaGeneratorConfig(listOf("app")))
val graphql = GraphQL.newGraphQL(schema).build()
val result = graphql.execute("""{ foo(bar: "baz") { name, age } }""").toSpecification()
companion object {
@JvmStatic
fun main(args: Array<String>) {
val schema =
toSchema(
queries = listOf(TopLevelObject(Query())),
config = SchemaGeneratorConfig(listOf("app")),
)
val graphql = GraphQL.newGraphQL(schema).build()
val result = graphql.execute("""{ foo(bar: "baz") { name, age } }""").toSpecification()

println(result)
}
println(result)
}
}
}
2 changes: 2 additions & 0 deletions examples/trivial/app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ kt_jvm_library(
ktlint_test(
name = "lint_test",
srcs = glob(["**/*.kt"]),
config = "//:ktlint_editorconfig",
)

ktlint_fix(
name = "lint_fix",
srcs = glob(["**/*.kt"]),
config = "//:ktlint_editorconfig",
)

java_binary(
Expand Down
3 changes: 1 addition & 2 deletions src/main/kotlin/io/bazel/kotlin/builder/cmd/Build.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ object Build {
.build()
.work(),
)
}
.run(::exitProcess)
}.run(::exitProcess)
}
}
3 changes: 1 addition & 2 deletions src/main/kotlin/io/bazel/kotlin/builder/cmd/MergeJdeps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ object MergeJdeps {
Worker
.from(args.toList()) {
start(DaggerJdepsMergerComponent.builder().build().work())
}
.run(::exitProcess)
}.run(::exitProcess)
}
}
22 changes: 14 additions & 8 deletions src/main/kotlin/io/bazel/kotlin/builder/tasks/CompileKotlin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@ import io.bazel.worker.Work
import io.bazel.worker.WorkerContext
import javax.inject.Inject

class CompileKotlin @Inject constructor(private val builder: KotlinBuilder) : Work {
override fun invoke(ctx: WorkerContext.TaskContext, args: Iterable<String>): Status {
return if (builder.build(ctx, args.toList()) != 0) {
Status.ERROR
} else {
Status.SUCCESS
}
class CompileKotlin
@Inject
constructor(
private val builder: KotlinBuilder,
) : Work {
override fun invoke(
ctx: WorkerContext.TaskContext,
args: Iterable<String>,
): Status =
if (builder.build(ctx, args.toList()) != 0) {
Status.ERROR
} else {
Status.SUCCESS
}
}
}
Loading

0 comments on commit fe0d460

Please sign in to comment.