tools/clippy: Allow json formatted output

This helps with integration of `tools/clippy` in `rust-analyzer` and
potentially other IDEs which can parse the json output better than the
text output.

TEST=Ran it with `rust-analyzer` in VSCode.

Change-Id: Iceb2748994cbbacf48dc473a9ad06eec567beb0a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3630700
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vaibhav Nagarnaik <vnagarnaik@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
Vaibhav Nagarnaik 2022-05-05 16:56:47 +00:00 committed by Chromeos LUCI
parent 71902a2af5
commit 235d76e9d2

View file

@ -30,12 +30,13 @@ def is_crate_excluded(crate: str) -> bool:
return crate in excluded_crates return crate in excluded_crates
def main(fix: bool = False): def main(fix: bool = False, json: bool = False):
chdir(CROSVM_ROOT) chdir(CROSVM_ROOT)
# Note: Clippy checks are configured in .cargo/config.toml # Note: Clippy checks are configured in .cargo/config.toml
common_args = [ common_args = [
"--fix" if fix else None, "--fix" if fix else None,
"--message-format=json" if json else None,
"--all-targets", "--all-targets",
"--", "--",
"-Dwarnings", "-Dwarnings",