David Tolnay | 39acbdd | 2019-04-12 15:45:32 -0700 | [diff] [blame] | 1 | #!/bin/bash |
Jakub Staron | 4197d3a | 2019-06-05 15:43:43 -0700 | [diff] [blame] | 2 | # 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 Kempin | 3a6b7f1 | 2021-11-12 09:35:42 -0800 | [diff] [blame] | 6 | # To check for violations: |
| 7 | # $ ./tools/clippy |
| 8 | # |
| 9 | # To fix violations where possible: |
| 10 | # $ ./tools/clippy --fix |
| 11 | |
Dennis Kempin | 10e7900 | 2021-11-11 15:14:38 -0800 | [diff] [blame] | 12 | set -e |
| 13 | cd "$(dirname $0)/.." |
David Tolnay | 39acbdd | 2019-04-12 15:45:32 -0700 | [diff] [blame] | 14 | |
Dennis Kempin | 10e7900 | 2021-11-11 15:14:38 -0800 | [diff] [blame] | 15 | # TODO(b/192373803): Clean up clippy error is the following crates |
| 16 | EXCLUDE=( |
| 17 | aarch64 # 16 errors |
Dennis Kempin | 10e7900 | 2021-11-11 15:14:38 -0800 | [diff] [blame] | 18 | crosvm-fuzz # 7 errors |
| 19 | devices # 92 errors |
| 20 | disk # 36 errors |
Dennis Kempin | 10e7900 | 2021-11-11 15:14:38 -0800 | [diff] [blame] | 21 | kvm # 641 errors |
| 22 | kvm_sys # 613 errors |
Dennis Kempin | 10e7900 | 2021-11-11 15:14:38 -0800 | [diff] [blame] | 23 | libvda # 79 errors |
| 24 | net_sys # 3 errors |
Dennis Kempin | 10e7900 | 2021-11-11 15:14:38 -0800 | [diff] [blame] | 25 | virtio_sys # 9 errors |
Dennis Kempin | 10e7900 | 2021-11-11 15:14:38 -0800 | [diff] [blame] | 26 | x86_64 # 56 errors |
Dennis Kempin | 50a58f9 | 2021-06-23 11:34:31 -0700 | [diff] [blame] | 27 | ) |
Dennis Kempin | 50a58f9 | 2021-06-23 11:34:31 -0700 | [diff] [blame] | 28 | |
Dennis Kempin | 10e7900 | 2021-11-11 15:14:38 -0800 | [diff] [blame] | 29 | EXCLUDE_COMMON=( |
Dennis Kempin | 10e7900 | 2021-11-11 15:14:38 -0800 | [diff] [blame] | 30 | common/cros_async # 8 errors |
Dennis Kempin | 10e7900 | 2021-11-11 15:14:38 -0800 | [diff] [blame] | 31 | ) |
Daniel Verkamp | 043aaea | 2020-04-15 11:41:50 -0700 | [diff] [blame] | 32 | |
Dennis Kempin | 3a6b7f1 | 2021-11-12 09:35:42 -0800 | [diff] [blame] | 33 | # Note: Clippy checks are configured in .cargo/config.toml |
Dennis Kempin | 10e7900 | 2021-11-11 15:14:38 -0800 | [diff] [blame] | 34 | echo "Clippy crosvm workspace" |
| 35 | cargo clippy \ |
| 36 | --workspace \ |
| 37 | --features all-linux \ |
| 38 | --all-targets \ |
| 39 | ${EXCLUDE[@]/#/--exclude } \ |
Dennis Kempin | 3a6b7f1 | 2021-11-12 09:35:42 -0800 | [diff] [blame] | 40 | "$@" -- -Dwarnings |
Dennis Kempin | 10e7900 | 2021-11-11 15:14:38 -0800 | [diff] [blame] | 41 | |
| 42 | for crate in common/*; do |
| 43 | if [ -d "${crate}" ] && |
| 44 | [[ ! " ${EXCLUDE_COMMON[*]} " =~ " ${crate} " ]]; then |
| 45 | echo "" |
| 46 | echo "Clippy ${crate}" |
Dennis Kempin | 3a6b7f1 | 2021-11-12 09:35:42 -0800 | [diff] [blame] | 47 | (cd "${crate}" && cargo clippy --all-targets "$@" -- -Dwarnings) |
Dennis Kempin | 10e7900 | 2021-11-11 15:14:38 -0800 | [diff] [blame] | 48 | fi |
| 49 | done |