Skip to content

Commit 2707e48

Browse files
committed
test: Add ktlint test to bazel build.
1 parent 134bbee commit 2707e48

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ jobs:
3232
runs-on: ubuntu-22.04
3333
steps:
3434
- uses: actions/checkout@v4
35-
- run: curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.1.1/ktlint && chmod a+x ktlint
35+
- run: curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.49.1/ktlint && chmod a+x ktlint
3636
- run: ./ktlint

BUILD.bazel

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_proto_library")
22
load("@rules_java//java:defs.bzl", "java_proto_library")
33
load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library", "kt_jvm_test")
4+
load("@rules_kotlin//kotlin:lint.bzl", "ktlint_fix", "ktlint_test")
45
load("@rules_proto//proto:defs.bzl", "proto_library")
56
load("//tools/project:build_defs.bzl", "project")
67

@@ -95,3 +96,14 @@ kt_jvm_test(
9596
"@maven//:org_jetbrains_kotlinx_kotlinx_coroutines_core",
9697
],
9798
)
99+
100+
ktlint_fix(
101+
name = "ktlint_fix",
102+
srcs = glob(["**/*.kt"]),
103+
)
104+
105+
ktlint_test(
106+
name = "ktlint_test",
107+
size = "small",
108+
srcs = glob(["**/*.kt"]),
109+
)
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package im.tox.tox4j.exceptions
22

3-
abstract class ToxException constructor(val code: Enum<*>, private val extraMessage: String) :
4-
Exception(extraMessage) {
5-
final override val message: String
6-
get() =
7-
when (extraMessage) {
8-
"" -> "Error code: " + code.name
9-
else -> extraMessage + ", error code: " + code.name
10-
}
11-
}
3+
abstract class ToxException(
4+
val code: Enum<*>,
5+
private val extraMessage: String,
6+
) : Exception(extraMessage) {
7+
final override val message: String
8+
get() =
9+
when (extraMessage) {
10+
"" -> "Error code: " + code.name
11+
else -> extraMessage + ", error code: " + code.name
12+
}
13+
}

0 commit comments

Comments
 (0)