Skip to content

Commit 0dcea98

Browse files
committed
Enforce clippy lints on test code in CI
Now that we've fixed many of the lints clippy cares about for our test code, switch to enforcing the lints in `--tests` as well. We disable a few lints that require substantial number of changes to our existing tests, sadly, though they'd probably be good changes to make at some point.
1 parent 0999a9b commit 0dcea98

File tree

1 file changed

+110
-102
lines changed

1 file changed

+110
-102
lines changed

ci/check-lint.sh

Lines changed: 110 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,113 @@
11
#!/bin/sh
22
set -e
33
set -x
4-
RUSTFLAGS='-D warnings' cargo clippy -- \
5-
`# Things clippy defaults to allowing but we should avoid` \
6-
-D clippy::clone_on_ref_ptr \
7-
`# Things where clippy is just wrong` \
8-
-A clippy::unwrap-or-default \
9-
-A clippy::upper_case_acronyms \
10-
`# Things where we do odd stuff on purpose ` \
11-
-A clippy::unusual_byte_groupings \
12-
-A clippy::unit_arg \
13-
`# Errors` \
14-
-A clippy::erasing_op \
15-
-A clippy::never_loop \
16-
`# Warnings` \
17-
-A renamed_and_removed_lints \
18-
-A clippy::blocks_in_conditions \
19-
-A clippy::borrow_deref_ref \
20-
-A clippy::clone_on_copy \
21-
-A clippy::collapsible_else_if \
22-
-A clippy::collapsible_if \
23-
-A clippy::collapsible_match \
24-
-A clippy::comparison_chain \
25-
-A clippy::doc_lazy_continuation \
26-
-A clippy::drain_collect \
27-
-A clippy::drop_non_drop \
28-
-A clippy::enum_variant_names \
29-
-A clippy::explicit_auto_deref \
30-
-A clippy::extra_unused_lifetimes \
31-
-A clippy::for_kv_map \
32-
-A clippy::from_over_into \
33-
-A clippy::get_first \
34-
-A clippy::identity_op \
35-
-A clippy::if_same_then_else \
36-
-A clippy::inconsistent_digit_grouping \
37-
-A clippy::iter_kv_map \
38-
-A clippy::iter_skip_next \
39-
-A clippy::large_enum_variant \
40-
-A clippy::legacy_numeric_constants \
41-
-A clippy::len_without_is_empty \
42-
-A clippy::len_zero \
43-
-A clippy::let_and_return \
44-
-A clippy::manual_div_ceil `# to be removed once we hit MSRV 1.73.0` \
45-
-A clippy::manual_filter \
46-
-A clippy::manual_map \
47-
-A clippy::manual_memcpy \
48-
-A clippy::manual_inspect \
49-
-A clippy::manual_range_contains \
50-
-A clippy::manual_range_patterns \
51-
-A clippy::manual_saturating_arithmetic \
52-
-A clippy::manual_strip \
53-
-A clippy::map_clone \
54-
-A clippy::map_flatten \
55-
-A clippy::match_like_matches_macro \
56-
-A clippy::match_ref_pats \
57-
-A clippy::multiple_bound_locations \
58-
-A clippy::mut_mutex_lock \
59-
-A clippy::needless_bool \
60-
-A clippy::needless_borrow \
61-
-A clippy::needless_borrowed_reference \
62-
-A clippy::needless_borrows_for_generic_args \
63-
-A clippy::needless_lifetimes \
64-
-A clippy::needless_question_mark \
65-
-A clippy::needless_range_loop \
66-
-A clippy::needless_return \
67-
-A clippy::new_without_default \
68-
-A clippy::non_minimal_cfg \
69-
-A clippy::op_ref \
70-
-A clippy::option_as_ref_deref \
71-
-A clippy::option_map_or_none \
72-
-A clippy::option_map_unit_fn \
73-
-A clippy::precedence \
74-
-A clippy::ptr_arg \
75-
-A clippy::question_mark \
76-
-A clippy::readonly_write_lock \
77-
-A clippy::redundant_closure \
78-
-A clippy::redundant_field_names \
79-
-A clippy::redundant_guards \
80-
-A clippy::redundant_pattern_matching \
81-
-A clippy::redundant_slicing \
82-
-A clippy::redundant_static_lifetimes \
83-
-A clippy::result_large_err \
84-
-A clippy::result_unit_err \
85-
-A clippy::search_is_some \
86-
-A clippy::single_char_pattern \
87-
-A clippy::single_match \
88-
-A clippy::slow_vector_initialization \
89-
-A clippy::tabs_in_doc_comments \
90-
-A clippy::to_string_in_format_args \
91-
-A clippy::too_many_arguments \
92-
-A clippy::toplevel_ref_arg \
93-
-A clippy::type_complexity \
94-
-A clippy::unnecessary_cast \
95-
-A clippy::unnecessary_get_then_check \
96-
-A clippy::unnecessary_lazy_evaluations \
97-
-A clippy::unnecessary_mut_passed \
98-
-A clippy::unnecessary_sort_by \
99-
-A clippy::unnecessary_to_owned \
100-
-A clippy::unnecessary_unwrap \
101-
-A clippy::unused_unit \
102-
-A clippy::useless_conversion \
103-
-A clippy::unnecessary_map_or `# to be removed once we hit MSRV 1.70` \
104-
-A clippy::manual_repeat_n `# to be removed once we hit MSRV 1.86` \
105-
-A clippy::io_other_error `# to be removed once we hit MSRV 1.74`
4+
5+
CLIPPY() {
6+
# shellcheck disable=SC2086
7+
RUSTFLAGS='-D warnings' cargo clippy $1 -- $2 \
8+
`# Things clippy defaults to allowing but we should avoid` \
9+
-D clippy::clone_on_ref_ptr \
10+
`# Things where clippy is just wrong` \
11+
-A clippy::unwrap-or-default \
12+
-A clippy::upper_case_acronyms \
13+
`# Things where we do odd stuff on purpose ` \
14+
-A clippy::unusual_byte_groupings \
15+
-A clippy::unit_arg \
16+
`# Errors` \
17+
-A clippy::erasing_op \
18+
-A clippy::never_loop \
19+
`# Warnings` \
20+
-A renamed_and_removed_lints \
21+
-A clippy::blocks_in_conditions \
22+
-A clippy::borrow_deref_ref \
23+
-A clippy::clone_on_copy \
24+
-A clippy::collapsible_else_if \
25+
-A clippy::collapsible_if \
26+
-A clippy::collapsible_match \
27+
-A clippy::comparison_chain \
28+
-A clippy::doc_lazy_continuation \
29+
-A clippy::drain_collect \
30+
-A clippy::drop_non_drop \
31+
-A clippy::enum_variant_names \
32+
-A clippy::explicit_auto_deref \
33+
-A clippy::extra_unused_lifetimes \
34+
-A clippy::for_kv_map \
35+
-A clippy::from_over_into \
36+
-A clippy::get_first \
37+
-A clippy::identity_op \
38+
-A clippy::if_same_then_else \
39+
-A clippy::inconsistent_digit_grouping \
40+
-A clippy::iter_kv_map \
41+
-A clippy::iter_skip_next \
42+
-A clippy::large_enum_variant \
43+
-A clippy::legacy_numeric_constants \
44+
-A clippy::len_without_is_empty \
45+
-A clippy::len_zero \
46+
-A clippy::let_and_return \
47+
-A clippy::manual_div_ceil `# to be removed once we hit MSRV 1.73.0` \
48+
-A clippy::manual_filter \
49+
-A clippy::manual_map \
50+
-A clippy::manual_memcpy \
51+
-A clippy::manual_inspect \
52+
-A clippy::manual_range_contains \
53+
-A clippy::manual_range_patterns \
54+
-A clippy::manual_saturating_arithmetic \
55+
-A clippy::manual_strip \
56+
-A clippy::map_clone \
57+
-A clippy::map_flatten \
58+
-A clippy::match_like_matches_macro \
59+
-A clippy::match_ref_pats \
60+
-A clippy::multiple_bound_locations \
61+
-A clippy::mut_mutex_lock \
62+
-A clippy::needless_bool \
63+
-A clippy::needless_borrow \
64+
-A clippy::needless_borrowed_reference \
65+
-A clippy::needless_borrows_for_generic_args \
66+
-A clippy::needless_lifetimes \
67+
-A clippy::needless_question_mark \
68+
-A clippy::needless_range_loop \
69+
-A clippy::needless_return \
70+
-A clippy::new_without_default \
71+
-A clippy::non_minimal_cfg \
72+
-A clippy::op_ref \
73+
-A clippy::option_as_ref_deref \
74+
-A clippy::option_map_or_none \
75+
-A clippy::option_map_unit_fn \
76+
-A clippy::precedence \
77+
-A clippy::ptr_arg \
78+
-A clippy::question_mark \
79+
-A clippy::readonly_write_lock \
80+
-A clippy::redundant_closure \
81+
-A clippy::redundant_field_names \
82+
-A clippy::redundant_guards \
83+
-A clippy::redundant_pattern_matching \
84+
-A clippy::redundant_slicing \
85+
-A clippy::redundant_static_lifetimes \
86+
-A clippy::result_large_err \
87+
-A clippy::result_unit_err \
88+
-A clippy::search_is_some \
89+
-A clippy::single_char_pattern \
90+
-A clippy::single_match \
91+
-A clippy::slow_vector_initialization \
92+
-A clippy::tabs_in_doc_comments \
93+
-A clippy::to_string_in_format_args \
94+
-A clippy::too_many_arguments \
95+
-A clippy::toplevel_ref_arg \
96+
-A clippy::type_complexity \
97+
-A clippy::unnecessary_cast \
98+
-A clippy::unnecessary_get_then_check \
99+
-A clippy::unnecessary_lazy_evaluations \
100+
-A clippy::unnecessary_mut_passed \
101+
-A clippy::unnecessary_sort_by \
102+
-A clippy::unnecessary_to_owned \
103+
-A clippy::unnecessary_unwrap \
104+
-A clippy::unused_unit \
105+
-A clippy::useless_conversion \
106+
-A clippy::unnecessary_map_or `# to be removed once we hit MSRV 1.70` \
107+
-A clippy::manual_repeat_n `# to be removed once we hit MSRV 1.86` \
108+
-A clippy::io_other_error `# to be removed once we hit MSRV 1.74`
109+
}
110+
111+
CLIPPY
112+
# We allow some additional warnings in tests which we should fix, but which aren't currently a priority
113+
CLIPPY --tests "-A clippy::bool_assert_comparison -A clippy::assertions_on_constants -A clippy::needless-late-init -A clippy::field_reassign_with_default -A clippy::unnecessary_literal_unwrap -A clippy::useless_vec"

0 commit comments

Comments
 (0)