crosvm/tools/clippy
Dennis Kempin 1dab58a2cf Update all copyright headers to match new style
This search/replace updates all copyright notices to drop the
"All rights reserved", Use "ChromiumOS" instead of "Chromium OS"
and drops the trailing dots.

This fulfills the request from legal and unifies our notices.

./tools/health-check has been updated to only accept this style.

BUG=b:246579983
TEST=./tools/health-check

Change-Id: I87a80701dc651f1baf4820e5cc42469d7c5f5bf7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3894243
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-09-13 18:41:29 +00:00

66 lines
1.9 KiB
Python
Executable file

#!/usr/bin/env python3
# Copyright 2019 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# To check for violations:
# $ ./tools/clippy
#
# To fix violations where possible:
# $ ./tools/clippy --fix
import os
from impl.common import CROSVM_ROOT, cwd, run_main, cmd, chdir
from impl.test_runner import get_workspace_excludes
from impl.test_target import Triple
clippy = cmd("cargo clippy").with_color_flag()
excluded_crates: list[str] = list(get_workspace_excludes(Triple.host_default()))
features: str = ""
if os.name == "posix":
features = "--features=all-linux"
elif os.name != "nt":
raise Exception(f"Unsupported build target: {os.name}")
def is_crate_excluded(crate: str) -> bool:
return crate in excluded_crates
def main(fix: bool = False, json: bool = False, locked: bool = False):
chdir(CROSVM_ROOT)
# Note: Clippy checks are configured in .cargo/config.toml
common_args = [
"--fix" if fix else None,
"--message-format=json" if json else None,
"--locked" if locked else None,
"--all-targets",
"--",
"-Dwarnings",
]
print("Clippy crosvm workspace")
clippy(
"--workspace",
features,
*[f"--exclude={crate}" for crate in excluded_crates],
*common_args,
).fg()
for crate in CROSVM_ROOT.glob("common/*/Cargo.toml"):
# TODO(b/213147081): remove the cros_async exclude this once
# common/cros_async is gone.
if is_crate_excluded(crate.parent.name) or (
os.name == "nt" and crate.parent.name == "cros_async"
):
print("Skipping crate", crate.parent.relative_to(CROSVM_ROOT))
else:
print("Clippy", crate.parent.relative_to(CROSVM_ROOT))
with cwd(crate.parent):
clippy("--all-features", *common_args).fg()
if __name__ == "__main__":
run_main(main)