Skip to content

Commit

Permalink
Create a linter management tool in Rust
Browse files Browse the repository at this point in the history
This replaces the one in XTask. Why a replacement?

* XTask abstractions are complicated, and meant to support many
  different use cases. The needs for a series of linting tool are
  simple.
* It was too hard to modify the existing code to improve ignore
  mangement, concurrent linting, etc.
* We are trying to move away from XTask for other things, and possibly
  remove the code completely.

Improvements in this tool:
* Clearly organized linter tool implementations. It's really easy to
  create new ones now.
* Use `ignore` crate to automatically take advantage of `.gitignore`,
  and other custom ignore files.
* Use ignore::WalkParallel to run lint jobs concurrentl. Check-format
  used to take me around 30 seconds, now it takes 3-5s.
* Remove a lot of the noise for successful lints.
* All files are processed, even if there is a failure. So you can get
  all of the formatting errors in one report.

Change-Id: I6156889dc99f499dd5d0a6787eca7d73dc12b6cc
  • Loading branch information
jblebrun committed Jun 25, 2024
1 parent b0db98c commit b07fc5b
Show file tree
Hide file tree
Showing 25 changed files with 1,959 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .lintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
third_party/
**/generated/
**/jni/
stage0_bin/supply-chain
linter/tests/testdata
77 changes: 77 additions & 0 deletions Cargo.bazel.lock
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,16 @@ dependencies = [
"tokio",
]

[[package]]
name = "bstr"
version = "1.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706"
dependencies = [
"memchr",
"serde",
]

[[package]]
name = "bumpalo"
version = "3.16.0"
Expand Down Expand Up @@ -494,6 +504,16 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422"

[[package]]
name = "colored"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8"
dependencies = [
"lazy_static",
"windows-sys 0.48.0",
]

[[package]]
name = "command-fds"
version = "0.3.0"
Expand Down Expand Up @@ -545,6 +565,31 @@ dependencies = [
"cfg-if",
]

[[package]]
name = "crossbeam-deque"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d"
dependencies = [
"crossbeam-epoch",
"crossbeam-utils",
]

[[package]]
name = "crossbeam-epoch"
version = "0.9.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
dependencies = [
"crossbeam-utils",
]

[[package]]
name = "crossbeam-utils"
version = "0.8.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"

[[package]]
name = "crunchy"
version = "0.2.2"
Expand Down Expand Up @@ -742,6 +787,7 @@ dependencies = [
"bytes",
"ciborium",
"clap",
"colored",
"command-fds",
"coset",
"curve25519-dalek",
Expand All @@ -754,6 +800,8 @@ dependencies = [
"hex",
"hkdf",
"hpke",
"ignore",
"lazy_static",
"libm",
"linked_list_allocator",
"lock_api",
Expand Down Expand Up @@ -1106,6 +1154,19 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"

[[package]]
name = "globset"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1"
dependencies = [
"aho-corasick",
"bstr",
"log",
"regex-automata",
"regex-syntax",
]

[[package]]
name = "goblin"
version = "0.8.0"
Expand Down Expand Up @@ -1357,6 +1418,22 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"

[[package]]
name = "ignore"
version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1"
dependencies = [
"crossbeam-deque",
"globset",
"log",
"memchr",
"regex-automata",
"same-file",
"walkdir",
"winapi-util",
]

[[package]]
name = "indexmap"
version = "1.9.3"
Expand Down
3 changes: 3 additions & 0 deletions bazel/crates/oak_crates_index.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def oak_crates_index(cargo_lockfile, lockfile):
],
version = "*",
),
"colored": crate.spec(version = "*"),
"command-fds": crate.spec(
features = ["tokio"],
version = "*",
Expand Down Expand Up @@ -165,6 +166,8 @@ def oak_crates_index(cargo_lockfile, lockfile):
],
version = "*",
),
"ignore": crate.spec(version = "*"),
"lazy_static": crate.spec(version = "*"),
"libm": crate.spec(version = "*"),
"linked_list_allocator": crate.spec(
features = [
Expand Down
77 changes: 77 additions & 0 deletions bazel/test_workspace/Cargo-test.bazel.lock
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,16 @@ dependencies = [
"tokio",
]

[[package]]
name = "bstr"
version = "1.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706"
dependencies = [
"memchr",
"serde",
]

[[package]]
name = "bumpalo"
version = "3.16.0"
Expand Down Expand Up @@ -500,6 +510,16 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422"

[[package]]
name = "colored"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8"
dependencies = [
"lazy_static",
"windows-sys 0.48.0",
]

[[package]]
name = "command-fds"
version = "0.3.0"
Expand Down Expand Up @@ -551,6 +571,31 @@ dependencies = [
"cfg-if",
]

[[package]]
name = "crossbeam-deque"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d"
dependencies = [
"crossbeam-epoch",
"crossbeam-utils",
]

[[package]]
name = "crossbeam-epoch"
version = "0.9.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
dependencies = [
"crossbeam-utils",
]

[[package]]
name = "crossbeam-utils"
version = "0.8.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"

[[package]]
name = "crunchy"
version = "0.2.2"
Expand Down Expand Up @@ -748,6 +793,7 @@ dependencies = [
"bytes",
"ciborium",
"clap",
"colored",
"command-fds",
"coset",
"curve25519-dalek",
Expand All @@ -760,6 +806,8 @@ dependencies = [
"hex",
"hkdf",
"hpke",
"ignore",
"lazy_static",
"libm",
"linked_list_allocator",
"lock_api",
Expand Down Expand Up @@ -1112,6 +1160,19 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"

[[package]]
name = "globset"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1"
dependencies = [
"aho-corasick",
"bstr",
"log",
"regex-automata",
"regex-syntax",
]

[[package]]
name = "goblin"
version = "0.8.2"
Expand Down Expand Up @@ -1363,6 +1424,22 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"

[[package]]
name = "ignore"
version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1"
dependencies = [
"crossbeam-deque",
"globset",
"log",
"memchr",
"regex-automata",
"same-file",
"walkdir",
"winapi-util",
]

[[package]]
name = "indexmap"
version = "1.9.3"
Expand Down
Loading

0 comments on commit b07fc5b

Please sign in to comment.