Skip to content

Commit b4e2ee9

Browse files
authored
chore: setup checkstyle linter for Java (#346)
1 parent ad64858 commit b4e2ee9

File tree

7 files changed

+39
-4
lines changed

7 files changed

+39
-4
lines changed

.aspect/cli/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ plugins:
1313
lint:
1414
aspects:
1515
- //tools/lint:linters.bzl%buf
16+
- //tools/lint:linters.bzl%checkstyle
1617
- //tools/lint:linters.bzl%clang_tidy
1718
- //tools/lint:linters.bzl%eslint
1819
- //tools/lint:linters.bzl%shellcheck

BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ exports_files(
1717
".ruff.toml",
1818
".shellcheckrc",
1919
"buf.yaml",
20+
"checkstyle.xml",
2021
"pmd.xml",
2122
"pyproject.toml",
2223
],

MODULE.bazel

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
bazel_dep(name = "apple_support", version = "1.11.1")
99
bazel_dep(name = "aspect_bazel_lib", version = "2.8.0")
1010
bazel_dep(name = "aspect_rules_js", version = "2.0.0")
11-
bazel_dep(name = "aspect_rules_lint", version = "1.0.0-rc9")
11+
bazel_dep(name = "aspect_rules_lint", version = "1.0.0-rc10")
1212
bazel_dep(name = "aspect_rules_swc", version = "2.0.0")
1313
bazel_dep(name = "aspect_rules_ts", version = "3.0.0")
1414
bazel_dep(name = "bazel_skylib", version = "1.4.2")
@@ -48,6 +48,12 @@ http_archive(
4848
url = "https://github.com/pmd/pmd/releases/download/pmd_releases/6.55.0/pmd-bin-6.55.0.zip",
4949
)
5050

51+
http_jar(
52+
name = "com_puppycrawl_tools_checkstyle",
53+
sha256 = "51c34d738520c1389d71998a9ab0e6dabe0d7cf262149f3e01a7294496062e42",
54+
url = "https://github.com/checkstyle/checkstyle/releases/download/checkstyle-10.17.0/checkstyle-10.17.0-all.jar",
55+
)
56+
5157
http_jar(
5258
name = "google-java-format",
5359
sha256 = "33068bbbdce1099982ec1171f5e202898eb35f2919cf486141e439fc6e3a4203",

MODULE.bazel.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

checkstyle.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
4+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
5+
<module name="Checker">
6+
7+
<module name="TreeWalker">
8+
<module name="UnusedImports"/>
9+
</module>
10+
11+
<module name="LineLength">
12+
<property name="max" value="90"/>
13+
</module>
14+
15+
</module>

tools/lint/BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,9 @@ native_binary(
3838
),
3939
out = "clang_tidy",
4040
)
41+
42+
java_binary(
43+
name = "checkstyle",
44+
main_class = "com.puppycrawl.tools.checkstyle.Main",
45+
runtime_deps = ["@com_puppycrawl_tools_checkstyle//jar"],
46+
)

tools/lint/linters.bzl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"Define linter aspects"
22

33
load("@aspect_rules_lint//lint:buf.bzl", "lint_buf_aspect")
4+
load("@aspect_rules_lint//lint:checkstyle.bzl", "lint_checkstyle_aspect")
45
load("@aspect_rules_lint//lint:clang_tidy.bzl", "lint_clang_tidy_aspect")
56
load("@aspect_rules_lint//lint:eslint.bzl", "lint_eslint_aspect")
67
load("@aspect_rules_lint//lint:pmd.bzl", "lint_pmd_aspect")
@@ -46,3 +47,8 @@ pmd = lint_pmd_aspect(
4647
binary = "@@//tools/lint:pmd",
4748
rulesets = ["@@//:pmd.xml"],
4849
)
50+
51+
checkstyle = lint_checkstyle_aspect(
52+
binary = "@@//tools/lint:checkstyle",
53+
config = "@@//:checkstyle.xml",
54+
)

0 commit comments

Comments
 (0)