blob: 794e65f1e9d7f2326a45b9efff9afc6c1347de20 [file] [log] [blame]
David Tolnay39acbdd2019-04-12 15:45:32 -07001#!/bin/bash
Jakub Staron4197d3a2019-06-05 15:43:43 -07002# Copyright 2019 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
Dennis Kempin3a6b7f12021-11-12 09:35:42 -08006# To check for violations:
7# $ ./tools/clippy
8#
9# To fix violations where possible:
10# $ ./tools/clippy --fix
11
Dennis Kempin10e79002021-11-11 15:14:38 -080012set -e
13cd "$(dirname $0)/.."
David Tolnay39acbdd2019-04-12 15:45:32 -070014
Dennis Kempin10e79002021-11-11 15:14:38 -080015# TODO(b/192373803): Clean up clippy error is the following crates
16EXCLUDE=(
17 aarch64 # 16 errors
Dennis Kempin10e79002021-11-11 15:14:38 -080018 crosvm-fuzz # 7 errors
19 devices # 92 errors
20 disk # 36 errors
Dennis Kempin10e79002021-11-11 15:14:38 -080021 kvm # 641 errors
22 kvm_sys # 613 errors
Dennis Kempin10e79002021-11-11 15:14:38 -080023 libvda # 79 errors
24 net_sys # 3 errors
Dennis Kempin10e79002021-11-11 15:14:38 -080025 virtio_sys # 9 errors
Dennis Kempin10e79002021-11-11 15:14:38 -080026 x86_64 # 56 errors
Dennis Kempin50a58f92021-06-23 11:34:31 -070027)
Dennis Kempin50a58f92021-06-23 11:34:31 -070028
Dennis Kempin10e79002021-11-11 15:14:38 -080029EXCLUDE_COMMON=(
Dennis Kempin10e79002021-11-11 15:14:38 -080030 common/cros_async # 8 errors
Dennis Kempin10e79002021-11-11 15:14:38 -080031)
Daniel Verkamp043aaea2020-04-15 11:41:50 -070032
Dennis Kempin3a6b7f12021-11-12 09:35:42 -080033# Note: Clippy checks are configured in .cargo/config.toml
Dennis Kempin10e79002021-11-11 15:14:38 -080034echo "Clippy crosvm workspace"
35cargo clippy \
36 --workspace \
37 --features all-linux \
38 --all-targets \
39 ${EXCLUDE[@]/#/--exclude } \
Dennis Kempin3a6b7f12021-11-12 09:35:42 -080040 "$@" -- -Dwarnings
Dennis Kempin10e79002021-11-11 15:14:38 -080041
42for crate in common/*; do
43 if [ -d "${crate}" ] &&
44 [[ ! " ${EXCLUDE_COMMON[*]} " =~ " ${crate} " ]]; then
45 echo ""
46 echo "Clippy ${crate}"
Dennis Kempin3a6b7f12021-11-12 09:35:42 -080047 (cd "${crate}" && cargo clippy --all-targets "$@" -- -Dwarnings)
Dennis Kempin10e79002021-11-11 15:14:38 -080048 fi
49done