提交 e56c9a52 编写于 作者: M Matthias Krüger

cargo dev crater: gather and save lint statistics (how often a lint triggered)

上级 4ec9cb84
......@@ -224,7 +224,30 @@ pub fn run() {
.flatten()
.collect();
let all_msgs: Vec<String> = clippy_warnings.iter().map(|warning| warning.to_string()).collect();
// generate some stats:
// count lint type occurrences
let mut counter: HashMap<&String, usize> = HashMap::new();
clippy_warnings
.iter()
.for_each(|wrn| *counter.entry(&wrn.linttype).or_insert(0) += 1);
// collect into a tupled list for sorting
let mut stats: Vec<(&&String, &usize)> = counter.iter().map(|(lint, count)| (lint, count)).collect();
// sort by number of lint occurences
stats.sort_by_key(|(_, count)| *count);
// biggest number first
stats.reverse();
let stats_formatted: String = stats
.iter()
.map(|(lint, count)| format!("{} {}\n", lint, count))
.collect::<String>();
let mut all_msgs: Vec<String> = clippy_warnings.iter().map(|warning| warning.to_string()).collect();
all_msgs.sort();
all_msgs.push("\n\n\n\nStats\n\n".into());
all_msgs.push(stats_formatted);
// save the text into mini-crater/logs.txt
let text = all_msgs.join("");
......
......@@ -3247,3 +3247,115 @@ xsv/0.13.0/src/select.rs:99:17 clippy::similar_names "binding's name is too simi
xsv/0.13.0/src/util.rs:150:5 clippy::doc_markdown "you should put bare URLs between `<`/`>` or make a proper Markdown link"
xsv/0.13.0/src/util.rs:37:33 clippy::map_clone "you are using an explicit closure for copying elements"
xsv/0.13.0/src/util.rs:90:1 clippy::needless_lifetimes "explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)"
Stats
clippy::must_use_candidate 552
clippy::unreadable_literal 365
clippy::missing_errors_doc 338
clippy::doc_markdown 178
clippy::wildcard_imports 160
clippy::items_after_statements 139
clippy::module_name_repetitions 137
clippy::redundant_closure_for_method_calls 135
clippy::redundant_field_names 111
clippy::cast_possible_truncation 91
clippy::similar_names 79
clippy::match_same_arms 64
clippy::inline_always 59
clippy::single_match_else 45
clippy::unseparated_literal_suffix 41
clippy::enum_glob_use 40
clippy::cast_precision_loss 35
clippy::if_not_else 35
clippy::filter_map 31
clippy::too_many_lines 31
clippy::redundant_else 29
clippy::trivially_copy_pass_by_ref 26
clippy::cast_lossless 23
clippy::redundant_static_lifetimes 21
clippy::struct_excessive_bools 20
clippy::map_unwrap_or 20
clippy::unusual_byte_groupings 19
clippy::unused_self 19
clippy::cast_possible_wrap 19
clippy::cast_sign_loss 19
clippy::unnecessary_wraps 19
clippy::needless_pass_by_value 18
clippy::default_trait_access 16
clippy::linkedlist 14
clippy::single_char_add_str 14
clippy::shadow_unrelated 13
clippy::cargo_common_metadata 13
clippy::option_if_let_else 12
clippy::needless_lifetimes 12
clippy::multiple_crate_versions 11
clippy::needless_doctest_main 10
clippy::missing_safety_doc 10
clippy::manual_range_contains 10
clippy::match_wildcard_for_single_variants 10
clippy::find_map 9
clippy::wrong_self_convention 8
clippy::invalid_upcast_comparisons 8
clippy::option_map_unit_fn 7
clippy::map_clone 7
clippy::explicit_into_iter_loop 7
clippy::range_plus_one 7
clippy::manual_strip 6
clippy::non_ascii_literal 6
clippy::single_component_path_imports 6
clippy::field_reassign_with_default 5
clippy::new_without_default 5
clippy::len_without_is_empty 5
clippy::identity_op 5
clippy::needless_return 5
clippy::empty_enum 5
clippy::match_like_matches_macro 5
clippy::explicit_iter_loop 5
clippy::too_many_arguments 4
clippy::let_underscore_drop 4
clippy::if_same_then_else 4
clippy::filter_map_next 3
clippy::zero_ptr 3
clippy::fn_params_excessive_bools 3
clippy::mut_mut 3
clippy::manual_non_exhaustive 2
clippy::comparison_to_empty 2
clippy::question_mark 2
clippy::redundant_pattern_matching 2
clippy::write_with_newline 2
clippy::unnecessary_cast 2
clippy::option_option 2
clippy::match_on_vec_items 2
clippy::type_complexity 2
clippy::len_zero 2
clippy::expl_impl_clone_on_copy 2
clippy::option_as_ref_deref 2
clippy::unused_unit 2
clippy::derive_hash_xor_eq 2
clippy::while_let_on_iterator 1
clippy::clone_on_copy 1
clippy::same_item_push 1
clippy::from_iter_instead_of_collect 1
clippy::or_fun_call 1
clippy::pub_enum_variant_names 1
clippy::used_underscore_binding 1
clippy::precedence 1
clippy::redundant_clone 1
clippy::collapsible_if 1
clippy::stable_sort_primitive 1
clippy::unit_arg 1
clippy::nonminimal_bool 1
clippy::comparison_chain 1
clippy::mem_replace_with_default 1
clippy::manual_saturating_arithmetic 1
clippy::expect_fun_call 1
clippy::should_implement_trait 1
clippy::verbose_bit_mask 1
clippy::int_plus_one 1
clippy::unnecessary_lazy_evaluations 1
clippy::from_over_into 1
clippy::explicit_deref_methods 1
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册