Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Most commonly ignored lints on crates.io #7666

Closed
dtolnay opened this issue Sep 13, 2021 · 23 comments
Closed

Most commonly ignored lints on crates.io #7666

dtolnay opened this issue Sep 13, 2021 · 23 comments
Labels
A-category Area: Categorization of lints C-tracking-issue Category: Tracking Issue S-needs-discussion Status: Needs further discussion before merging or work can be started

Comments

@dtolnay
Copy link
Member

dtolnay commented Sep 13, 2021

This is a similar methodology to #5418, but using all published crates on crates.io as the data source, rather than repos indexed by grep.app. The old table is a year and a half out of date at this point and hard to reproduce, so I've gone ahead and closed that issue. The code to generate the table below is in https://github.com/dtolnay/noisy-clippy.

The global column is counting #![allow(...)] attributes indicating that a lint has been suppressed at the whole crate or module level, and local is counting #[allow(...)] where a lint has been suppressed at only one place it is being triggered. The table is sorted by the sum.

local global lint name category
3311 519 type_complexity complexity
2369 526 too_many_arguments complexity
2175 79 wrong_self_convention style
827 390 upper_case_acronyms style
236 966 all unknown
855 70 cast_ptr_alignment correctness pedantic
619 285 many_single_char_names pedantic
722 125 large_enum_variant perf
707 132 cognitive_complexity complexity nursery
334 473 unreadable_literal style pedantic
29 774 let_unit_value style pedantic
620 163 cast_possible_truncation pedantic
485 164 float_cmp correctness
247 384 module_name_repetitions pedantic
506 94 trivially_copy_pass_by_ref perf pedantic
381 125 needless_pass_by_value style pedantic
418 82 identity_op complexity
458 29 unwrap_used restriction
401 75 new_ret_no_self style
358 105 cast_sign_loss pedantic
393 64 unnecessary_wraps complexity pedantic
229 225 missing_safety_doc style
339 109 should_implement_trait style
248 179 new_without_default style
338 34 missing_inline_in_public_items restriction
265 106 too_many_lines pedantic
285 59 len_without_is_empty style
205 114 module_inception style
157 142 integer_arithmetic restriction
234 64 needless_range_loop style
194 94 use_self nursery
227 54 ptr_arg style
33 230 needless_doctest_main style
218 44 suspicious_arithmetic_impl suspicious
167 90 cast_possible_wrap pedantic
34 211 missing_errors_doc pedantic
133 110 excessive_precision style
104 139 from_over_into style
37 203 must_use_candidate pedantic
187 47 missing_const_for_fn nursery
153 71 cast_precision_loss pedantic
94 125 cast_lossless pedantic
142 74 redundant_closure style
115 94 not_unsafe_ptr_arg_deref correctness
142 64 single_match style
124 72 let_and_return style
138 55 needless_lifetimes complexity
72 117 similar_names pedantic
170 16 useless_conversion complexity
65 121 wildcard_imports pedantic
93 91 match_single_binding complexity
159 23 unused_self pedantic
29 151 doc_markdown pedantic
114 61 match_same_arms pedantic
172 3 mut_from_ref correctness
137 38 unknown_clippy_lints unknown
135 37 eq_op correctness
116 53 missing_panics_doc pedantic
118 44 collapsible_if style
146 8 clone_on_copy complexity
62 90 approx_constant correctness
33 115 needless_return style
117 29 redundant_clone perf
116 29 redundant_pub_crate nursery
120 22 enum_variant_names style
69 69 inline_always pedantic
105 33 type_repetition_in_bounds pedantic
115 21 derive_hash_xor_eq correctness
43 92 non_ascii_literal pedantic
73 60 option_if_let_else pedantic nursery
90 31 comparison_chain style
59 61 match_like_matches_macro style
57 62 shadow_unrelated pedantic
79 40 transmute_ptr_to_ptr pedantic
57 61 missing_docs_in_private_items restriction
84 34 used_underscore_binding pedantic
97 20 if_same_then_else correctness
21 94 unused_unit style
0 111 multiple_crate_versions cargo
105 4 expect_used restriction
71 37 mutex_atomic perf
57 50 indexing_slicing restriction
90 12 borrowed_box complexity
46 56 unit_arg complexity
25 69 field_reassign_with_default style
76 18 result_unit_err style
15 77 default_trait_access pedantic
86 5 uninit_assumed_init correctness
79 10 mut_mut pedantic
54 35 never_loop correctness
81 7 map_entry perf
69 17 exhaustive_structs restriction
21 65 redundant_field_names style
51 34 suspicious_op_assign_impl suspicious
79 5 erasing_op correctness
54 29 as_conversions restriction
57 26 implicit_hasher style pedantic
49 32 or_fun_call perf
18 62 print_stdout restriction
61 17 assertions_on_constants style
66 11 needless_collect perf
40 37 op_ref style
68 8 pattern_type_mismatch restriction
47 28 suspicious_else_formatting suspicious
55 20 wildcard_enum_match_arm restriction
60 14 cyclomatic_complexity unknown
56 16 range_plus_one complexity pedantic
14 58 single_match_else pedantic
58 13 reversed_empty_ranges correctness
18 52 assign_op_pattern style
30 39 blacklisted_name style
22 47 match_bool style pedantic
48 21 struct_excessive_bools pedantic
19 49 if_not_else pedantic
56 12 option_option complexity pedantic
58 10 rc_buffer perf restriction
21 46 enum_glob_use pedantic
64 3 suspicious_operation_groupings style nursery
59 6 empty_loop suspicious
46 18 inconsistent_digit_grouping style
54 10 mutable_key_type suspicious
0 62 implicit_return restriction
44 18 zero_prefixed_literal complexity
9 52 redundant_static_lifetimes style
61 0 ref_option_ref pedantic
53 6 clone_double_ref correctness
51 8 match_wild_err_arm style pedantic
21 36 borrow_interior_mutable_const correctness style
49 8 declare_interior_mutable_const correctness style
46 11 useless_attribute correctness
41 15 eval_order_dependence suspicious
44 12 semicolon_if_nothing_returned pedantic
36 18 collapsible_else_if style
14 40 redundant_closure_call complexity
53 0 drop_bounds unknown
32 21 unnecessary_cast complexity
39 13 ptr_offset_with_cast complexity
23 29 pub_enum_variant_names deprecated
18 33 manual_range_contains style
26 24 deref_addrof complexity
13 36 items_after_statements pedantic
42 6 let_underscore_must_use restriction
45 3 same_item_push style
38 8 boxed_local perf
38 8 exhaustive_enums restriction
39 6 branches_sharing_code nursery
38 7 map_clone style
18 27 useless_transmute nursery
1 43 tabs_in_doc_comments style
19 24 panic restriction
2 41 unseparated_literal_suffix pedantic
40 3 while_let_on_iterator style
27 15 map_err_ignore restriction
14 27 float_arithmetic restriction
15 26 shadow_reuse restriction
28 12 blocks_in_if_conditions style
26 14 manual_map style
28 12 manual_strip complexity
1 38 nonstandard_macro_braces style nursery
9 30 pedantic unknown
12 27 string_lit_as_bytes style nursery
33 6 unnecessary_unwrap complexity
34 5 vec_box complexity
18 21 write_with_newline style
38 0 zero_sized_map_values pedantic
0 37 dbg_macro restriction
26 11 redundant_pattern_matching style
13 24 unneeded_field_pattern restriction
19 18 useless_let_if_seq style nursery
30 6 absurd_extreme_comparisons correctness
34 1 cast_ref_to_mut correctness
18 17 filter_map deprecated
19 16 new_without_default_derive unknown
16 19 single_component_path_imports style
26 9 trivial_regex style nursery
12 22 integer_division pedantic restriction
21 13 len_zero style
26 8 needless_bool complexity
14 20 unusual_byte_groupings style
1 32 deprecated_cfg_attr complexity
30 2 extra_unused_lifetimes complexity
22 10 nonminimal_bool complexity
0 31 blanket_clippy_restriction_lints suspicious
25 6 partialeq_ne_impl complexity
30 0 derive_ord_xor_partial_ord correctness
17 13 stutter unknown
9 21 unnested_or_patterns complexity pedantic
3 26 else_if_without_else restriction
25 4 forget_copy correctness
3 26 let_underscore_drop pedantic
18 11 vec_init_then_push perf
12 16 bool_comparison complexity
14 13 empty_enum pedantic
15 12 option_unwrap_used unknown
14 12 fallible_impl_from nursery
16 10 manual_non_exhaustive style
15 11 needless_update complexity
14 12 suspicious_map suspicious
10 15 match_wildcard_for_single_variants pedantic
11 14 use_debug restriction
23 1 no_effect complexity
13 11 print_literal style
1 23 redundant_else pedantic
4 20 renamed_and_removed_lints unknown
13 11 unit_cmp correctness
22 1 into_iter_on_ref style
15 8 neg_cmp_op_on_partial_ord complexity
7 16 toplevel_ref_arg style
12 11 unnecessary_operation complexity
18 4 drop_copy correctness
11 11 expect_fun_call perf
12 10 inherent_to_string style
12 10 transmute_ptr_to_ref complexity
14 7 explicit_counter_loop complexity
5 16 match_ref_pats style
13 8 suboptimal_flops nursery
14 7 unimplemented restriction
1 20 unreachable restriction
17 4 wildcard_in_or_patterns complexity
21 0 zero_ptr style
15 5 iter_nth_zero style
8 12 option_map_unit_fn complexity
9 10 block_in_if_condition_stmt unknown
13 6 int_plus_one complexity
12 7 result_unwrap_used unknown
7 11 complexity unknown
4 14 expl_impl_clone_on_copy pedantic
2 16 precedence complexity
4 14 try_err style
5 13 verbose_bit_mask style pedantic
0 17 clone_on_ref_ptr restriction
13 4 while_let_loop complexity
11 5 cmp_owned perf
12 4 identity_conversion unknown
7 9 just_underscores_and_digits style
8 8 needless_borrow style
16 0 needless_continue pedantic
9 7 vtable_address_comparisons correctness
12 3 collapsible_match style
1 14 style unknown
0 14 cargo_common_metadata cargo
7 7 future_not_send nursery
12 2 option_as_ref_deref complexity
11 3 redundant_allocation perf
14 0 stable_sort_primitive perf
7 6 bool_assert_comparison style
12 1 mem_forget restriction
8 5 useless_vec perf
8 4 await_holding_refcell_ref correctness pedantic
11 1 box_vec perf
1 11 checked_conversions pedantic
3 9 from_iter_instead_of_collect pedantic
10 2 manual_filter_map complexity
6 6 redundant_closure_for_method_calls pedantic
5 7 unused_io_amount correctness
10 1 mem_discriminant_non_enum correctness
4 7 ptr_as_ptr pedantic
8 3 unnecessary_mut_passed style
3 7 const_static_lifetime unknown
7 3 debug_assert_with_mut_call nursery
9 1 drop_ref correctness
10 0 filter_next complexity
10 0 manual_flatten complexity
0 10 multiple_inherent_impl restriction
1 9 nursery unknown
4 6 redundant_slicing complexity
6 4 unsafe_derive_deserialize pedantic
1 8 explicit_iter_loop pedantic
9 0 forget_ref correctness
8 1 match_overlapping_arm style
2 7 panic_in_result_fn restriction
6 3 single_char_pattern perf
5 4 write_literal style
4 4 clippy unknown
1 7 decimal_literal_representation restriction
7 1 fn_address_comparisons correctness
8 0 infallible_destructuring_match style
6 2 manual_memcpy perf
0 8 match_on_vec_items pedantic
0 8 modulo_arithmetic restriction
8 0 size_of_in_element_count correctness
5 3 unused_async pedantic
1 7 useless_format complexity
6 1 await_holding_lock correctness pedantic
0 7 default_numeric_fallback restriction
6 1 explicit_deref_methods pedantic
7 0 inherent_to_string_shadow_display correctness
6 1 neg_multiply style
0 7 option_map_unwrap_or unknown
0 7 option_map_unwrap_or_else unknown
7 0 unnecessary_sort_by complexity
5 2 unwrap_in_result restriction
5 1 double_parens complexity
4 2 get_unwrap restriction
5 1 manual_swap complexity
0 6 map_unwrap_or pedantic
1 5 mem_replace_with_default style
1 5 option_expect_used unknown
1 5 result_expect_used unknown
1 4 cargo unknown
2 3 empty_line_after_outer_attr nursery
2 3 enum_clike_unportable_variant correctness
3 2 exit restriction
4 1 into_iter_on_array unknown
3 2 manual_async_fn style
5 0 maybe_infinite_iter pedantic
4 1 question_mark style
4 1 unnecessary_filter_map complexity
0 5 wildcard_dependencies cargo
5 0 zero_divided_by_zero complexity
0 4 find_map deprecated
2 2 float_equality_without_abs suspicious
2 2 inefficient_to_string perf pedantic
3 1 manual_unwrap_or complexity
4 0 mut_range_bound suspicious
3 1 naive_bytecount pedantic
0 4 needless_arbitrary_self_type complexity
1 3 needless_question_mark complexity
0 4 possible_missing_comma correctness
2 2 range_minus_one pedantic
4 0 while_immutable_condition correctness
3 0 bad_bit_mask correctness
3 0 case_sensitive_file_extension_comparisons pedantic
0 3 cmp_null style
1 2 comparison_to_empty style
1 2 crosspointer_transmute complexity
3 0 disallowed_method nursery
1 2 explicit_into_iter_loop pedantic
0 3 float_cmp_const restriction
3 0 for_kv_map style
3 0 ifs_same_cond correctness
3 0 map_identity complexity
3 0 ok_expect style
0 3 perf unknown
2 1 print_with_newline style
0 3 shadow_same restriction
2 1 single_char_add_str style
3 0 useless_asref complexity
2 0 char_lit_as_u8 complexity
0 2 cloned_instead_of_copied pedantic
0 2 diverging_sub_expression complexity
0 2 double_must_use style
2 0 for_loops_over_fallibles suspicious
2 0 from_str_radix_10 style
2 0 if_let_redundant_pattern_matching deprecated
1 1 invalid_regex correctness
2 0 invisible_characters correctness
2 0 let_underscore_lock correctness
1 1 linkedlist pedantic
2 0 logic_bug correctness
1 1 manual_find_map complexity
1 1 match_as_ref complexity
2 0 mistyped_literal_suffixes correctness
0 2 mixed_case_hex_literals style
2 0 modulo_one correctness
0 2 needless_for_each pedantic
0 2 non_upper_case_globals unknown
2 0 out_of_bounds_indexing correctness
1 1 panic_params unknown
0 2 panicking_unwrap correctness
1 1 redundant_pattern style
0 2 restriction unknown
1 1 same_functions_in_if_condition pedantic
0 2 string_add restriction
2 0 string_extend_chars style
0 2 suspicious_assignment_formatting suspicious
2 0 transmuting_null correctness
2 0 unnecessary_fold style
1 0 as_conversion unknown
1 0 async_yields_async correctness
0 1 clippy_complexity unknown
1 0 cmp_nan correctness
0 1 copy_iterator pedantic
0 1 create_dir restriction
0 1 deprecated_semver correctness
1 0 explicit_write complexity
1 0 extend_from_slice deprecated
1 0 filetype_is_file restriction
1 0 filter_map_identity complexity
1 0 fn_params_excessive_bools pedantic
1 0 if_let_some_result style
0 1 if_then_some_else_none restriction
0 1 inconsistent_struct_constructor pedantic
1 0 infinite_iter correctness
0 1 inline_asm_x86_intel_syntax restriction
1 0 inline_fn_without_body correctness
1 0 inspect_for_each complexity
1 0 invalid_ref unknown
0 1 iter_count complexity
1 0 iter_nth perf
0 1 large_digit_groups style pedantic
0 1 manual_saturating_arithmetic style
0 1 map_flatten pedantic
1 0 mem_replace_option_with_none style
0 1 mut_mutex_lock style
1 0 option_env_unwrap correctness
1 0 print_stderr restriction
0 1 ptr_eq style
0 1 regex_macro deprecated
0 1 replace_consts deprecated
0 1 result_map_unit_fn complexity
1 0 result_map_unwrap_or_else unknown
0 1 skip_while_next complexity
0 1 to_string_in_display correctness
0 1 todo restriction
0 1 transmute_float_to_int complexity
0 1 transmute_int_to_char complexity
1 0 transmute_int_to_float complexity
1 0 unnecessary_lazy_evaluations style
0 1 unsafe_removed_from_name style
1 0 unsound_collection_transmute correctness
0 1 unused_doc_comment unknown
0 1 unused_parens unknown
0 1 unused_results unknown
1 0 verbose_file_reads restriction
0 1 zero_width_space unknown

@rustbot label +A-category +C-tracking-issue +S-needs-discussion

@rustbot rustbot added A-category Area: Categorization of lints C-tracking-issue Category: Tracking Issue S-needs-discussion Status: Needs further discussion before merging or work can be started labels Sep 13, 2021
@camsteffen
Copy link
Contributor

This is an extremely helpful metric and it certainly lends itself to some specific changes. Thank you @dtolnay for all the work you've put in to making Clippy less annoying. 😃

@flip1995
Copy link
Member

I filtered out the allow-by-default lints and sorted this table by number of global and by local allows each:

Global
global local lint name category
966 236 all unknown
430 2326 too_many_arguments complexity
423 3283 type_complexity complexity
390 827 upper_case_acronyms style
274 616 many_single_char_names style
227 33 needless_doctest_main style
225 229 missing_safety_doc style
168 246 new_without_default style
159 474 float_cmp correctness
139 104 from_over_into style
120 700 large_enum_variant perf
114 26 needless_return style
111 202 module_inception style
109 132 excessive_precision style
102 331 should_implement_trait style
94 21 unused_unit style
91 111 not_unsafe_ptr_arg_deref correctness
91 93 match_single_binding complexity
89 62 approx_constant correctness
78 2167 wrong_self_convention style
78 418 identity_op complexity
73 396 new_ret_no_self style
71 139 redundant_closure style
70 123 let_and_return style
69 25 field_reassign_with_default style
61 59 match_like_matches_macro style
58 140 single_match style
57 279 len_without_is_empty style
56 221 needless_range_loop style
56 46 unit_arg complexity
54 137 needless_lifetimes complexity
52 225 ptr_arg style
51 18 assign_op_pattern style
48 9 redundant_static_lifetimes style
46 20 redundant_field_names style
43 217 suspicious_arithmetic_impl suspicious
43 1 tabs_in_doc_comments style
42 107 collapsible_if style
39 13 redundant_closure_call complexity
38 137 unknown_clippy_lints unknown
37 127 eq_op correctness
37 67 mutex_atomic perf
37 40 op_ref style
36 21 borrow_interior_mutable_const correctness style
34 51 suspicious_op_assign_impl suspicious
33 50 never_loop correctness
33 18 manual_range_contains style
32 49 or_fun_call perf
31 90 comparison_chain style
31 30 blacklisted_name style
31 0 blanket_clippy_restriction_lints suspicious
30 9 pedantic unknown
29 117 redundant_clone perf
29 23 pub_enum_variant_names deprecated
28 47 suspicious_else_formatting suspicious
27 1 deprecated_cfg_attr complexity
24 24 deref_addrof complexity
22 115 enum_variant_names style
21 32 unnecessary_cast complexity
20 111 derive_hash_xor_eq correctness
20 18 write_with_newline style
20 14 unusual_byte_groupings style
19 85 if_same_then_else correctness
19 16 single_component_path_imports style
18 46 inconsistent_digit_grouping style
18 36 collapsible_else_if style
17 61 assertions_on_constants style
17 18 filter_map deprecated
16 170 useless_conversion complexity
16 76 result_unit_err style
16 7 toplevel_ref_arg style
14 41 eval_order_dependence suspicious
14 26 manual_map style
14 1 style unknown
13 58 reversed_empty_ranges correctness
13 44 zero_prefixed_literal complexity
13 39 ptr_offset_with_cast complexity
13 21 len_zero style
13 12 bool_comparison complexity
13 4 try_err style
12 84 borrowed_box complexity
12 28 blocks_in_if_conditions style
12 28 manual_strip complexity
12 14 suspicious_map suspicious
12 8 option_map_unit_fn complexity
12 4 match_ref_pats style
11 66 needless_collect perf
11 40 useless_attribute correctness
11 26 redundant_pattern_matching style
11 18 vec_init_then_push perf
11 15 needless_update complexity
11 13 print_literal style
11 11 expect_fun_call perf
11 10 unit_cmp correctness
11 10 unnecessary_operation complexity
11 7 complexity unknown
10 54 mutable_key_type suspicious
10 16 manual_non_exhaustive style
10 12 inherent_to_string style
9 19 nonminimal_bool complexity
9 1 nursery unknown
8 144 clone_on_copy complexity
8 49 declare_interior_mutable_const correctness style
8 25 needless_bool complexity
8 15 neg_cmp_op_on_partial_ord complexity
8 8 block_in_if_condition_stmt unknown
7 74 map_entry perf
7 38 map_clone style
7 37 cyclomatic_complexity unknown
7 35 boxed_local perf
7 14 explicit_counter_loop complexity
7 12 transmute_ptr_to_ref complexity
7 7 just_underscores_and_digits style
7 5 unused_io_amount correctness
7 0 option_map_unwrap_or unknown
7 0 option_map_unwrap_or_else unknown
6 58 empty_loop suspicious
6 53 clone_double_ref correctness
6 33 unnecessary_unwrap complexity
6 30 absurd_extreme_comparisons correctness
6 25 partialeq_ne_impl complexity
6 13 int_plus_one complexity
6 8 needless_borrow style
6 7 bool_assert_comparison style
6 4 redundant_slicing complexity
6 2 precedence complexity
6 1 useless_format complexity
5 86 uninit_assumed_init correctness
5 79 erasing_op correctness
5 34 vec_box complexity
5 15 iter_nth_zero style
5 15 option_unwrap_used unknown
5 11 cmp_owned perf
5 8 useless_vec perf
5 7 stutter unknown
5 1 mem_replace_with_default style
5 1 option_expect_used unknown
5 1 result_expect_used unknown
4 25 forget_copy correctness
4 18 drop_copy correctness
4 17 wildcard_in_or_patterns complexity
4 11 result_unwrap_used unknown
4 9 identity_conversion unknown
4 4 write_literal style
4 1 cargo unknown
4 0 find_map deprecated
4 0 needless_arbitrary_self_type complexity
3 172 mut_from_ref correctness
3 45 same_item_push style
3 38 while_let_on_iterator style
3 12 collapsible_match style
3 11 redundant_allocation perf
3 11 while_let_loop complexity
3 8 unnecessary_mut_passed style
3 6 single_char_pattern perf
3 4 new_without_default_derive unknown
3 2 enum_clike_unportable_variant correctness
3 1 needless_question_mark complexity
3 0 cmp_null style
3 0 perf unknown
3 0 possible_missing_comma correctness
2 30 extra_unused_lifetimes complexity
2 12 option_as_ref_deref complexity
2 10 manual_filter_map complexity
2 9 vtable_address_comparisons correctness
2 6 manual_memcpy perf
2 3 manual_async_fn style
2 2 float_equality_without_abs suspicious
2 1 comparison_to_empty style
2 1 crosspointer_transmute complexity
2 0 const_static_lifetime unknown
2 0 diverging_sub_expression complexity
2 0 double_must_use style
2 0 mixed_case_hex_literals style
2 0 panicking_unwrap correctness
2 0 restriction unknown
2 0 suspicious_assignment_formatting suspicious
1 34 cast_ref_to_mut correctness
1 22 into_iter_on_ref style
1 20 no_effect complexity
1 11 box_vec perf
1 10 mem_discriminant_non_enum correctness
1 9 drop_ref correctness
1 8 match_overlapping_arm style
1 7 fn_address_comparisons correctness
1 6 neg_multiply style
1 5 double_parens complexity
1 5 manual_swap complexity
1 4 into_iter_on_array unknown
1 4 question_mark style
1 4 unnecessary_filter_map complexity
1 3 manual_unwrap_or complexity
1 2 single_char_add_str style
1 1 invalid_regex correctness
1 1 manual_find_map complexity
1 1 match_as_ref complexity
1 1 redundant_pattern style
1 0 deprecated_semver correctness
1 0 iter_count complexity
1 0 manual_saturating_arithmetic style
1 0 mut_mutex_lock style
1 0 panic_params unknown
1 0 ptr_eq style
1 0 replace_consts deprecated
1 0 result_map_unit_fn complexity
1 0 skip_while_next complexity
1 0 to_string_in_display correctness
1 0 transmute_int_to_char complexity
1 0 unsafe_removed_from_name style
1 0 zero_width_space unknown
0 53 drop_bounds unknown
0 30 derive_ord_xor_partial_ord correctness
0 21 zero_ptr style
0 14 stable_sort_primitive perf
0 10 filter_next complexity
0 10 manual_flatten complexity
0 9 forget_ref correctness
0 8 infallible_destructuring_match style
0 8 size_of_in_element_count correctness
0 7 inherent_to_string_shadow_display correctness
0 7 unnecessary_sort_by complexity
0 5 zero_divided_by_zero complexity
0 4 mut_range_bound suspicious
0 3 bad_bit_mask correctness
0 3 map_identity complexity
0 3 ok_expect style
0 3 while_immutable_condition correctness
0 2 char_lit_as_u8 complexity
0 2 for_kv_map style
0 2 for_loops_over_fallibles suspicious
0 2 from_str_radix_10 style
0 2 invisible_characters correctness
0 2 let_underscore_lock correctness
0 2 logic_bug correctness
0 2 mistyped_literal_suffixes correctness
0 2 modulo_one correctness
0 2 out_of_bounds_indexing correctness
0 2 print_with_newline style
0 2 string_extend_chars style
0 2 transmuting_null correctness
0 2 unnecessary_fold style
0 1 as_conversion unknown
0 1 async_yields_async correctness
0 1 cmp_nan correctness
0 1 explicit_write complexity
0 1 extend_from_slice deprecated
0 1 filter_map_identity complexity
0 1 if_let_some_result style
0 1 ifs_same_cond correctness
0 1 infinite_iter correctness
0 1 inline_fn_without_body correctness
0 1 inspect_for_each complexity
0 1 invalid_ref unknown
0 1 iter_nth perf
0 1 mem_replace_option_with_none style
0 1 option_env_unwrap correctness
0 1 result_map_unwrap_or_else unknown
0 1 transmute_int_to_float complexity
0 1 unnecessary_lazy_evaluations style
0 1 unsound_collection_transmute correctness
0 1 useless_asref complexity
Local
global local lint name category
423 3283 type_complexity complexity
430 2326 too_many_arguments complexity
78 2167 wrong_self_convention style
390 827 upper_case_acronyms style
120 700 large_enum_variant perf
274 616 many_single_char_names style
159 474 float_cmp correctness
78 418 identity_op complexity
73 396 new_ret_no_self style
102 331 should_implement_trait style
57 279 len_without_is_empty style
168 246 new_without_default style
966 236 all unknown
225 229 missing_safety_doc style
52 225 ptr_arg style
56 221 needless_range_loop style
43 217 suspicious_arithmetic_impl suspicious
111 202 module_inception style
3 172 mut_from_ref correctness
16 170 useless_conversion complexity
8 144 clone_on_copy complexity
58 140 single_match style
71 139 redundant_closure style
54 137 needless_lifetimes complexity
38 137 unknown_clippy_lints unknown
109 132 excessive_precision style
37 127 eq_op correctness
70 123 let_and_return style
29 117 redundant_clone perf
22 115 enum_variant_names style
91 111 not_unsafe_ptr_arg_deref correctness
20 111 derive_hash_xor_eq correctness
42 107 collapsible_if style
139 104 from_over_into style
91 93 match_single_binding complexity
31 90 comparison_chain style
5 86 uninit_assumed_init correctness
19 85 if_same_then_else correctness
12 84 borrowed_box complexity
5 79 erasing_op correctness
16 76 result_unit_err style
7 74 map_entry perf
37 67 mutex_atomic perf
11 66 needless_collect perf
89 62 approx_constant correctness
17 61 assertions_on_constants style
61 59 match_like_matches_macro style
13 58 reversed_empty_ranges correctness
6 58 empty_loop suspicious
10 54 mutable_key_type suspicious
6 53 clone_double_ref correctness
0 53 drop_bounds unknown
34 51 suspicious_op_assign_impl suspicious
33 50 never_loop correctness
32 49 or_fun_call perf
8 49 declare_interior_mutable_const correctness style
28 47 suspicious_else_formatting suspicious
56 46 unit_arg complexity
18 46 inconsistent_digit_grouping style
3 45 same_item_push style
13 44 zero_prefixed_literal complexity
14 41 eval_order_dependence suspicious
37 40 op_ref style
11 40 useless_attribute correctness
13 39 ptr_offset_with_cast complexity
7 38 map_clone style
3 38 while_let_on_iterator style
7 37 cyclomatic_complexity unknown
18 36 collapsible_else_if style
7 35 boxed_local perf
5 34 vec_box complexity
1 34 cast_ref_to_mut correctness
227 33 needless_doctest_main style
6 33 unnecessary_unwrap complexity
21 32 unnecessary_cast complexity
31 30 blacklisted_name style
6 30 absurd_extreme_comparisons correctness
2 30 extra_unused_lifetimes complexity
0 30 derive_ord_xor_partial_ord correctness
12 28 blocks_in_if_conditions style
12 28 manual_strip complexity
114 26 needless_return style
14 26 manual_map style
11 26 redundant_pattern_matching style
69 25 field_reassign_with_default style
8 25 needless_bool complexity
6 25 partialeq_ne_impl complexity
4 25 forget_copy correctness
24 24 deref_addrof complexity
29 23 pub_enum_variant_names deprecated
1 22 into_iter_on_ref style
94 21 unused_unit style
36 21 borrow_interior_mutable_const correctness style
13 21 len_zero style
0 21 zero_ptr style
46 20 redundant_field_names style
1 20 no_effect complexity
9 19 nonminimal_bool complexity
51 18 assign_op_pattern style
33 18 manual_range_contains style
20 18 write_with_newline style
17 18 filter_map deprecated
11 18 vec_init_then_push perf
4 18 drop_copy correctness
4 17 wildcard_in_or_patterns complexity
19 16 single_component_path_imports style
10 16 manual_non_exhaustive style
11 15 needless_update complexity
8 15 neg_cmp_op_on_partial_ord complexity
5 15 iter_nth_zero style
5 15 option_unwrap_used unknown
20 14 unusual_byte_groupings style
12 14 suspicious_map suspicious
7 14 explicit_counter_loop complexity
0 14 stable_sort_primitive perf
39 13 redundant_closure_call complexity
11 13 print_literal style
6 13 int_plus_one complexity
13 12 bool_comparison complexity
10 12 inherent_to_string style
7 12 transmute_ptr_to_ref complexity
3 12 collapsible_match style
2 12 option_as_ref_deref complexity
11 11 expect_fun_call perf
5 11 cmp_owned perf
4 11 result_unwrap_used unknown
3 11 redundant_allocation perf
3 11 while_let_loop complexity
1 11 box_vec perf
11 10 unit_cmp correctness
11 10 unnecessary_operation complexity
2 10 manual_filter_map complexity
1 10 mem_discriminant_non_enum correctness
0 10 filter_next complexity
0 10 manual_flatten complexity
48 9 redundant_static_lifetimes style
30 9 pedantic unknown
4 9 identity_conversion unknown
2 9 vtable_address_comparisons correctness
1 9 drop_ref correctness
0 9 forget_ref correctness
12 8 option_map_unit_fn complexity
8 8 block_in_if_condition_stmt unknown
6 8 needless_borrow style
5 8 useless_vec perf
3 8 unnecessary_mut_passed style
1 8 match_overlapping_arm style
0 8 infallible_destructuring_match style
0 8 size_of_in_element_count correctness
16 7 toplevel_ref_arg style
11 7 complexity unknown
7 7 just_underscores_and_digits style
6 7 bool_assert_comparison style
5 7 stutter unknown
1 7 fn_address_comparisons correctness
0 7 inherent_to_string_shadow_display correctness
0 7 unnecessary_sort_by complexity
3 6 single_char_pattern perf
2 6 manual_memcpy perf
1 6 neg_multiply style
7 5 unused_io_amount correctness
1 5 double_parens complexity
1 5 manual_swap complexity
0 5 zero_divided_by_zero complexity
13 4 try_err style
12 4 match_ref_pats style
6 4 redundant_slicing complexity
4 4 write_literal style
3 4 new_without_default_derive unknown
1 4 into_iter_on_array unknown
1 4 question_mark style
1 4 unnecessary_filter_map complexity
0 4 mut_range_bound suspicious
2 3 manual_async_fn style
1 3 manual_unwrap_or complexity
0 3 bad_bit_mask correctness
0 3 map_identity complexity
0 3 ok_expect style
0 3 while_immutable_condition correctness
6 2 precedence complexity
3 2 enum_clike_unportable_variant correctness
2 2 float_equality_without_abs suspicious
1 2 single_char_add_str style
0 2 char_lit_as_u8 complexity
0 2 for_kv_map style
0 2 for_loops_over_fallibles suspicious
0 2 from_str_radix_10 style
0 2 invisible_characters correctness
0 2 let_underscore_lock correctness
0 2 logic_bug correctness
0 2 mistyped_literal_suffixes correctness
0 2 modulo_one correctness
0 2 out_of_bounds_indexing correctness
0 2 print_with_newline style
0 2 string_extend_chars style
0 2 transmuting_null correctness
0 2 unnecessary_fold style
43 1 tabs_in_doc_comments style
27 1 deprecated_cfg_attr complexity
14 1 style unknown
9 1 nursery unknown
6 1 useless_format complexity
5 1 mem_replace_with_default style
5 1 option_expect_used unknown
5 1 result_expect_used unknown
4 1 cargo unknown
3 1 needless_question_mark complexity
2 1 comparison_to_empty style
2 1 crosspointer_transmute complexity
1 1 invalid_regex correctness
1 1 manual_find_map complexity
1 1 match_as_ref complexity
1 1 redundant_pattern style
0 1 as_conversion unknown
0 1 async_yields_async correctness
0 1 cmp_nan correctness
0 1 explicit_write complexity
0 1 extend_from_slice deprecated
0 1 filter_map_identity complexity
0 1 if_let_some_result style
0 1 ifs_same_cond correctness
0 1 infinite_iter correctness
0 1 inline_fn_without_body correctness
0 1 inspect_for_each complexity
0 1 invalid_ref unknown
0 1 iter_nth perf
0 1 mem_replace_option_with_none style
0 1 option_env_unwrap correctness
0 1 result_map_unwrap_or_else unknown
0 1 transmute_int_to_float complexity
0 1 unnecessary_lazy_evaluations style
0 1 unsound_collection_transmute correctness
0 1 useless_asref complexity
31 0 blanket_clippy_restriction_lints suspicious
7 0 option_map_unwrap_or unknown
7 0 option_map_unwrap_or_else unknown
4 0 find_map deprecated
4 0 needless_arbitrary_self_type complexity
3 0 cmp_null style
3 0 perf unknown
3 0 possible_missing_comma correctness
2 0 const_static_lifetime unknown
2 0 diverging_sub_expression complexity
2 0 double_must_use style
2 0 mixed_case_hex_literals style
2 0 panicking_unwrap correctness
2 0 restriction unknown
2 0 suspicious_assignment_formatting suspicious
1 0 deprecated_semver correctness
1 0 iter_count complexity
1 0 manual_saturating_arithmetic style
1 0 mut_mutex_lock style
1 0 panic_params unknown
1 0 ptr_eq style
1 0 replace_consts deprecated
1 0 result_map_unit_fn complexity
1 0 skip_while_next complexity
1 0 to_string_in_display correctness
1 0 transmute_int_to_char complexity
1 0 unsafe_removed_from_name style
1 0 zero_width_space unknown

I think the lints that are globally allowed very often are the first we should look at. The allow-by-default lints don't really need immediate action.

@dtolnay
Copy link
Member Author

dtolnay commented Sep 14, 2021

The top 2 most widely suppressed lints, whether you look at global or local, are too_many_arguments and type_complexity. Both of these happen to be configurable and it's possible Clippy has gotten the default thresholds wrong. I filed dtolnay/noisy-clippy#3 to look into collecting a histogram of the actual number of arguments and actual complexity among functions/types where those lints are being suppressed.

We should also collect info on the upper_case_acronyms cases. It's possible there is a relatively small number of heuristics Clippy is missing which account for the majority of cases.

many_single_char_names I would be amenable to bumping to pedantic without further scrutiny. This is just too domain specific for Clippy to have reliable visibility into. For example in the context of colors, a function using h, s, l, r, g, b is 100% sensible and spelling all those out is silly, but it's blown way past the default lint threshold.

needless_doctest_main is one that I am personally opposed to and would bump to restriction but I don't know how others feel. Module-level example code that shows anything more than a single line of code, and especially if it shows imports or trait impls, is just better with the statements collected into a function and main is as good as any.

@flip1995
Copy link
Member

many_single_char_names I would be amenable to bumping to pedantic without further scrutiny.

When I looked at the list, I also thought that by today's standards we'd probably place this lint in pedantic, so I'd be fine with moving it.

I don't have a strong opinion about needless_doctest_main, I think @llogiq is the best person to talk about this lint to. I agree with everything else you wrote.

@dtolnay
Copy link
Member Author

dtolnay commented Sep 14, 2021

For the rest, I think dtolnay/noisy-clippy#1 is gonna be a blocker for further action on a lot of them. We need a way to browse what is going on at each of these suppression sites.

I'd call out that not_unsafe_ptr_arg_deref is shockingly high. The lint seems airtight to me but I wonder if there is something we are missing or if people are just willingly writing unsound code.

I'm guessing from_over_into are all just left over from old rustc before the coherence rule rebalance but it's something we should check.

large_enum_variant has never been useful to me as a perf lint but I defer to the Clippy team whether to keep that one.

needless_return, assuming it isn't false positives somehow, is just people being wrong so we can ignore that.

module_inception has never been useful to me and I have disabled it several times.

wrong_self_convention needs to get all the suppression sites categorized. Clippy is likely missing some heuristics there judging by the massive number of local suppressed.

match_single_binding is documented to have a severe known false positive so nursery might be justified.

identity_op probably needs to be relaxed a bit. @oli-obk commented on this in #3866 (comment): "we should maybe just whitelist multiplying with constants".

bors added a commit that referenced this issue Sep 14, 2021
Downgrade many_single_char_names to pedantic

As suggested by `@flip1995` in #7666 (comment), by today's standards this lint would be considered `pedantic`.

This is one of the most widely suppressed Clippy lints on crates.io according to https://github.com/dtolnay/noisy-clippy.

In my opinion this lint is just too domain specific for Clippy to have reliable visibility into. Sure there are some cases where the author is just being lazy and could use a kick in the butt, but we're still left with an enormous number of suppressions where single chars are the most appropriate name. For example in the context of colors, a function using `h`, `s`, `l`, `r`, `g`, `b` is 100% sensible and spelling all those out is silly, but it's past the default lint threshold.

---

changelog: Moved [`many_single_char_names`] to `pedantic`
@Jarcho
Copy link
Contributor

Jarcho commented Sep 15, 2021

module_inception has never been useful to me and I have disabled it several times.

I'm curious when you're doing this. Is there some kind of pattern that could be allowed here? I'm also curious if this is actually a common beginner mistake, or if that's just an baseless assertion in the docs.

large_enum_variant has never been useful to me as a perf lint but I defer to the Clippy team whether to keep that one.

This one seems to not work properly.

enum Foo {
    X,
    Y([u8;255]),
    Z([u8;200]),
}

It's currently claiming X is the second largest variant on the playground.

I'd call out that not_unsafe_ptr_arg_deref is shockingly high. The lint seems airtight to me but I wonder if there is something we are missing or if people are just willingly writing unsound code.

I've seen people do that for private helper functions. It's not unsound as a whole assuming they're careful, but the individual function definitely is.


new_ret_no_self is probably due to false positives with generics.

len_without_is_empty is probably also due to false positives. At least partially.

new_without_default should probably only trigger on exported types. I've disabled this lint before on private types.

clone_on_copy is almost definitely false positives which are fixed now. (suggestion didn't account for derive having the wrong trait bounds)


It would probably be a good idea to filter on when the last update on the crate was. I imagine that would give a better idea into the current state of ignored lints.

@workingjubilee
Copy link
Member

workingjubilee commented Sep 19, 2021

excessive_precision is too severe: decimals intended as f32s with less than 9 significant digits are linted against, e.g.

    let x: f32 = 1.111_111_1;

This is 8 significant digits. It should permit at least 9, even if some are considered "excessive", because f32s can include up to 9 significant digits meaningfully, and there is various verbiage in the IEEE754 standard that provides guarantees around only float strings with at least 9 decimal digits. That little extra padding, means float parsing should always get the result and round it correctly. Likewise with f64, it should allow at least 17 before throwing a warning for the same reason.

The reasoning around float_cmp may be overly strict... Correct handling of floats is hard to address via a simple lint. It seems particularly puzzling as a correctness lint, as most correctness lints are Almost Certainly Wrong, as opposed to merely Likely. And there are many cases, if one "knows what one is doing" that exact float comparison is quite appropriate. A warning would be fine but even that might be a bit much.

Both of these are high on the frequent-allow list.

@workingjubilee
Copy link
Member

workingjubilee commented Sep 19, 2021

Several instances of #[allow(too_many_arguments)] on grep.app are for a new function. Since these are just building a complex struct, clippy should probably ignore these entirely.

For a typical procedure call, the System V AMD64 ABI allows passing up to 14 arguments in registers if 8 of them belong to the {x,y,z}mm registers (e.g. floats). The AAPCS64 is slightly more lenient: 16 arguments, for similar reasons. Actually, slightly more for both, but it gets increasingly conditional. It is common to have to pass multiple floats as arguments to e.g. OpenGL APIs, which are beyond the control of the Rust programmer, but for which additional abstraction improves nothing (and the functions are likely perf-sensitive, so may be bad, as occasionally useless code is generated by building and dismantling a struct). While I do not believe clippy should become aware of ABI details, and it's not clippy's fault that compilers are suboptimal, it may be justified to skip floats, or to separately count them, or to just raise the argument threshold by several increments to account for this.

@dtolnay
Copy link
Member Author

dtolnay commented Sep 19, 2021

I've updated the table at the top of this issue with links to browse the individual suppressions.


@ghost
Copy link

ghost commented Sep 20, 2021

It looks like a lot of the eq_op allows are in test code. You'd definitely want to test equal operands if you're implementing a binary operator.

@jhpratt
Copy link
Member

jhpratt commented Sep 23, 2021

I'd be curious to know how many of the #[allow]s for cognitive complexity were on tests. Personally I have it silenced for integration tests but still warned for the implementation. Similarly for too many lines.

@workingjubilee
Copy link
Member

It is possible that Clippy should omit a set of lints entirely inside #[test] code.

@jhpratt
Copy link
Member

jhpratt commented Sep 23, 2021

Along with integration tests, that was my thinking. Cognitive complexity, too many lines, a number of performance lints, etc.

@dtolnay
Copy link
Member Author

dtolnay commented Sep 26, 2021

For cast_possible_truncation: I think recognizing a fairly small group of correct idioms would make a huge difference in the number of suppressions necessary.

Someone will need to go through https://dtolnay.github.io/noisy-clippy/cast_possible_truncation.html and file obvious recognizable cases like #7486.

pub fn f(val: u64) {
    let digit = (val % 62) as u8;
    println!("{}", digit);
}
error: casting `u64` to `u8` may truncate the value
 --> src/main.rs:2:17
  |
2 |     let digit = (val % 62) as u8;
  |                 ^^^^^^^^^^^^^^^^

bors added a commit that referenced this issue Sep 27, 2021
Demote float_cmp to pedantic

See this issue: #7666

This is one of the most frequently suppressed lints. It is deny-by-default. It is not actually clearly wrong, as there are many instances where direct float comparison is actually desirable. It is only after operating on floats that they may lose precision, and that depends greatly on the operation. As most correctness lints have a much higher standard of error, being based on hard and fast binary logic, this should not be amongst them.

A linter is not a substitute for observing the math carefully and running tests, and doing the desirable thing is even more likely to lead one to want exact comparisons.

changelog: Demote [`float_cmp`] from correctness to pedantic lints
bors added a commit that referenced this issue Sep 30, 2021
fix bug for large_enum_variants

Fix the discussion problem in the issue of #7666 (comment)

About the false positive problem of case:
```rust
enum LargeEnum6 {
    A,
    B([u8;255]),
    C([u8;200]),
}
```
bors added a commit that referenced this issue Sep 30, 2021
fix bug for large_enum_variants

Fix the discussion problem in the issue of #7666 (comment)

About the false positive problem of case:
```rust
enum LargeEnum6 {
    A,
    B([u8;255]),
    C([u8;200]),
}
```

changelog: Fix largest_enum_variant wrongly identifying the second largest variant.
@wchargin
Copy link
Contributor

large_enum_variant has never been useful to me as a perf lint but I defer to the Clippy team whether to keep that one.

Random user here—this lint once singlehandedly sped up my application by
~30% end-to-end. I had an enum type that was being moved around in the
hot spot of the program, and boxing the expensive variant early on in
the pipeline reduced total memory usage and saved a lot of copies.

This kind of improvement definitely mattered for this program, so I have
something of a fondness for this lint now. No strong opinion about what
to do with it; just happened on this quoted comment and wanted to share
anecdata.

@llogiq
Copy link
Contributor

llogiq commented Oct 30, 2021

@mikerite eq_op no longer triggers in test code after #7811.
@dtolnay I also did some work to reduce cast_possible_truncation FPs in #7819, though there are likely other cases, so the detection could be extended. I'll also be OK with moving needless_doctest_main to restriction or pedantic, as this is certainly a question of style preferences.

@flip1995 flip1995 pinned this issue Nov 18, 2021
@JarrettBillingsley
Copy link

Throwing in another data point re: too_many_arguments, where the only time I ever ran into it was on new functions.

@dhardy
Copy link

dhardy commented Mar 22, 2022

I also think that needless_doctest_main should not be active by default: it affects output (documentation), which may have its own reasons for including or not including fn main, so it's not just a "code quality" lint.

@Stargateur
Copy link

Stargateur commented Apr 15, 2022

about redundant_pattern_matching, I'm not a big fan, I understand the know problem, but in my opinion, if you choice to ignore the inner value of Ok(_) and then rematch the value inside the if (so create a deadlock) you are doing something wrong in the first place by ignoring the inner value of Ok. Maybe there is some valid use case that would first need to check a is_ok() before but that seem fishy code.

I believe a better lint would be to check if the value is ignored and just after rematched.

if let Ok(_) = foo {
  let foo = foo.unwrap();
}

Thus I think this lint would be very hard to implement and probably would not handle complex case.

@flip1995
Copy link
Member

flip1995 commented Apr 15, 2022

@Stargateur the redundant_pattern_matching lint is a style lint. So it is not meant to detect problems in the code, but rather to improve code style. We @ Clippy think that foo.is_ok() over let Ok(_) = foo is slightly better style because it reads easier from left to write. "If foo is Ok" is more natural than let Ok be the same as foo". If you disagree with this style choice, you can just allow this lint in your code. style lints are designed to be the most opinionated warn-by-default lints in Clippy.

The lint you are suggesting already exists with if foo.is_ok(): Playground

@Stargateur
Copy link

the redundant_pattern_matching lint is a style lint. So it is not meant to detect problems in the code

It's still mark as warning so this made CI fail https://github.com/rust-pcap/pcap/runs/6034264950?check_suite_focus=true#step:9:18 (thus I just saw pcap deny warning but I expect a lot of project do that)

Anyway it's was my 2 cents about why this lint may be ignored sometime, fly away, thank for clippy ♥

@ridhwanc
Copy link

ridhwanc commented Jun 22, 2023

What does it mean for one these blocks in the table to have a strike-through? Does it mean the community deemed it as "not noisy"?

@flip1995
Copy link
Member

flip1995 commented Jun 23, 2023

Those lints are disabled by default. So unless you opt-in to using those lints, you won't have to allow them. And if you opt-in globally to one of those lints and then allow them throughout the crate, we don't consider that as bad-practice, but rather encourage this.

bors added a commit that referenced this issue Oct 13, 2024
Move `clippy::module_name_repetitions` to `restriction` (from `pedantic`)

Rational:
- Too pedantic IMO, I use `#[warn(pedantic)]` in my personal projects, but then always allow this lint. The fact that we had a few `#[expect(clippy::module_name_repetitions)]` also underlines this point IMO
- STD doesn't do this either. Examples:
  - std::vec::Vec
  - std::collections::vec_deque::VecDequeue
- #7666 commonly ignored

---

changelog: Move [`module_name_repetitions`] to `restriction` (from `pedantic`)
[#13541](#13541)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-category Area: Categorization of lints C-tracking-issue Category: Tracking Issue S-needs-discussion Status: Needs further discussion before merging or work can be started
Projects
None yet
Development

No branches or pull requests