mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-05 18:20:34 +00:00
tools/clippy: Move allow-list to .cargo/config.toml
This applies the same clippy config to rust_analyzer as well. BUG=b:193893457 TEST=./tools/clippy and VSCode show the same linter results Change-Id: I5deec4a24d71fec4692ed708664130f46c1311b0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3278773 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Dennis Kempin <denniskempin@google.com>
This commit is contained in:
parent
13f5e9b983
commit
3a6b7f11ce
2 changed files with 55 additions and 44 deletions
46
.cargo/config.toml
Normal file
46
.cargo/config.toml
Normal file
|
@ -0,0 +1,46 @@
|
|||
# Disable clippy lints project-wide.
|
||||
# This allows ./tools/clippy and IDE integrations to use the same configuration.
|
||||
# This should be replaced with a proper clippy config once available:
|
||||
# https://github.com/rust-lang/cargo/issues/5034
|
||||
[target.'cfg(all())']
|
||||
rustflags = [
|
||||
# TODO(b/181763000): Fail builds on warnings
|
||||
# "-Dwarnings",
|
||||
|
||||
# TODO(crbug/908640): To be resolved.
|
||||
"-Aclippy::collapsible_if", # 4 errors
|
||||
"-Aclippy::comparison_chain", # 1 errors
|
||||
"-Aclippy::missing_safety_doc", # 26 errors
|
||||
"-Aclippy::wrong_self_convention", # 8 errors
|
||||
"-Aclippy::upper_case_acronyms", # 1 errors
|
||||
"-Aclippy::from_over_into", # 1 errors
|
||||
"-Aclippy::let-and-return", # 1 errors
|
||||
|
||||
# False positives affecting WlVfd @ `devices/src/virtio/wl.rs`.
|
||||
# Bug: https://github.com/rust-lang/rust-clippy/issues/6312
|
||||
"-Aclippy::field_reassign_with_default",
|
||||
|
||||
# We don't care about these lints. Okay to remain suppressed globally.
|
||||
"-Aclippy::cast_lossless",
|
||||
"-Aclippy::cognitive_complexity",
|
||||
"-Aclippy::enum_variant_names",
|
||||
"-Aclippy::identity_op",
|
||||
"-Aclippy::len_without_is_empty",
|
||||
"-Aclippy::len_zero",
|
||||
"-Aclippy::match_bool",
|
||||
"-Aclippy::match_wild_err_arm",
|
||||
"-Aclippy::module_inception",
|
||||
"-Aclippy::needless_bool",
|
||||
"-Aclippy::new_without_default",
|
||||
"-Aclippy::or_fun_call",
|
||||
"-Aclippy::should_implement_trait",
|
||||
"-Aclippy::single_char_pattern",
|
||||
"-Aclippy::too_many_arguments",
|
||||
"-Aclippy::trivially_copy_pass_by_ref",
|
||||
"-Aclippy::type_complexity",
|
||||
"-Aclippy::unreadable_literal",
|
||||
"-Aclippy::useless_let_if_seq",
|
||||
"-Aclippy::useless_transmute",
|
||||
"-Aclippy::new-ret-no-self",
|
||||
"-Aclippy::result-unit-err",
|
||||
]
|
53
tools/clippy
53
tools/clippy
|
@ -3,48 +3,15 @@
|
|||
# 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
|
||||
|
||||
set -e
|
||||
cd "$(dirname $0)/.."
|
||||
|
||||
SUPPRESS=(
|
||||
# TODO(crbug/908640): To be resolved.
|
||||
collapsible_if # 4 errors
|
||||
comparison_chain # 1 error
|
||||
missing_safety_doc # 30 errors
|
||||
wrong_self_convention # 8 errors
|
||||
upper_case_acronyms # 1 errors
|
||||
from_over_into # 1 error
|
||||
let-and-return # 1 error
|
||||
|
||||
# False positives affecting WlVfd @ `devices/src/virtio/wl.rs`.
|
||||
# Bug: https://github.com/rust-lang/rust-clippy/issues/6312
|
||||
field_reassign_with_default
|
||||
|
||||
# We don't care about these lints. Okay to remain suppressed globally.
|
||||
cast_lossless
|
||||
cognitive_complexity
|
||||
enum_variant_names
|
||||
identity_op
|
||||
len_without_is_empty
|
||||
len_zero
|
||||
match_bool
|
||||
match_wild_err_arm
|
||||
module_inception
|
||||
needless_bool
|
||||
new_without_default
|
||||
or_fun_call
|
||||
should_implement_trait
|
||||
single_char_pattern
|
||||
too_many_arguments
|
||||
trivially_copy_pass_by_ref
|
||||
type_complexity
|
||||
unreadable_literal
|
||||
useless_let_if_seq
|
||||
useless_transmute
|
||||
new-ret-no-self
|
||||
result-unit-err
|
||||
)
|
||||
|
||||
# TODO(b/192373803): Clean up clippy error is the following crates
|
||||
EXCLUDE=(
|
||||
aarch64 # 16 errors
|
||||
|
@ -68,7 +35,6 @@ EXCLUDE=(
|
|||
virtio_sys # 9 errors
|
||||
vm_memory # 9 errors
|
||||
x86_64 # 56 errors
|
||||
|
||||
)
|
||||
|
||||
EXCLUDE_COMMON=(
|
||||
|
@ -79,21 +45,20 @@ EXCLUDE_COMMON=(
|
|||
common/sys_util # 2 errors
|
||||
)
|
||||
|
||||
CLIPPY_ARGS="-- ${SUPPRESS[@]/#/-Aclippy::} -D warnings $@"
|
||||
|
||||
# Note: Clippy checks are configured in .cargo/config.toml
|
||||
echo "Clippy crosvm workspace"
|
||||
cargo clippy \
|
||||
--workspace \
|
||||
--features all-linux \
|
||||
--all-targets \
|
||||
${EXCLUDE[@]/#/--exclude } \
|
||||
${CLIPPY_ARGS}
|
||||
"$@" -- -Dwarnings
|
||||
|
||||
for crate in common/*; do
|
||||
if [ -d "${crate}" ] &&
|
||||
[[ ! " ${EXCLUDE_COMMON[*]} " =~ " ${crate} " ]]; then
|
||||
echo ""
|
||||
echo "Clippy ${crate}"
|
||||
(cd "${crate}" && cargo clippy --all-targets ${CLIPPY_ARGS})
|
||||
(cd "${crate}" && cargo clippy --all-targets "$@" -- -Dwarnings)
|
||||
fi
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue