summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@chromium.org>2019-04-12 15:45:32 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-04-15 02:06:08 -0700
commit39acbdd53d7242130f14dfc5e301ddfb03218b8b (patch)
tree2263157fd5bd0d1781a1f24680ecdaebadbd38aa /bin
parentaecf9a4dee6c004bceabf268a5b36d24c3744ca6 (diff)
downloadcrosvm-39acbdd53d7242130f14dfc5e301ddfb03218b8b.tar
crosvm-39acbdd53d7242130f14dfc5e301ddfb03218b8b.tar.gz
crosvm-39acbdd53d7242130f14dfc5e301ddfb03218b8b.tar.bz2
crosvm-39acbdd53d7242130f14dfc5e301ddfb03218b8b.tar.lz
crosvm-39acbdd53d7242130f14dfc5e301ddfb03218b8b.tar.xz
crosvm-39acbdd53d7242130f14dfc5e301ddfb03218b8b.tar.zst
crosvm-39acbdd53d7242130f14dfc5e301ddfb03218b8b.zip
clippy: Add script to run Clippy on crosvm
The script suppresses all currently failing lints. I broke this down
into lints that I believe are worth addressing and lints that I wouldn't
mind keeping suppressed indefinitely.

TEST=bin/clippy

Change-Id: I967f3292ce2f790907619e87fe9f5a23bfef4cf4
Reviewed-on: https://chromium-review.googlesource.com/1566652
Commit-Ready: David Tolnay <dtolnay@chromium.org>
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Tolnay <dtolnay@chromium.org>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/clippy75
1 files changed, 75 insertions, 0 deletions
diff --git a/bin/clippy b/bin/clippy
new file mode 100755
index 0000000..a7a70c1
--- /dev/null
+++ b/bin/clippy
@@ -0,0 +1,75 @@
+#!/bin/bash
+
+# Run `cargo clippy` on all Rust code in crosvm with a mindful set of lints
+# suppressed.
+
+set -euo pipefail
+
+# Change into directory of script, which is crosvm/bin.
+cd "$(dirname "${BASH_SOURCE[0]}")"
+
+# Jump up to root directory of crosvm repo.
+cd ..
+
+SUPPRESS=(
+    # To be resolved.
+    assign_op_pattern
+    block_in_if_condition_stmt
+    clone_on_copy
+    collapsible_if
+    const_static_lifetime
+    extra_unused_lifetimes
+    into_iter_on_array
+    let_and_return
+    let_unit_value
+    match_ref_pats
+    needless_return
+    option_map_unit_fn
+    question_mark
+    range_plus_one
+    redundant_closure
+    redundant_pattern_matching
+    single_match
+    string_lit_as_bytes
+    toplevel_ref_arg
+    unit_arg
+    unneeded_field_pattern
+    unused_unit
+    useless_format
+    while_let_loop
+
+    # To be resolved or suppressed locally.
+    absurd_extreme_comparisons
+    cast_ptr_alignment
+    if_same_then_else
+    ptr_arg
+
+    # We don't care about these lints. Okay to remain suppressed globally.
+    blacklisted_name
+    cast_lossless
+    cyclomatic_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
+    transmute_ptr_to_ptr
+    trivially_copy_pass_by_ref
+    type_complexity
+    unreadable_literal
+    useless_let_if_seq
+    useless_transmute
+)
+
+# Needed or else clippy won't re-run on code that has already compiled.
+cargo clean
+
+cargo clippy --all-features -- ${SUPPRESS[@]/#/-Aclippy::} "$@"