Don't use an exact lint counter anymore

This commit is contained in:
flip1995 2020-03-31 17:23:14 +02:00
parent 5de019074b
commit 3155eedb68
No known key found for this signature in database
GPG Key ID: 2CEFCDB27ED0BE79
3 changed files with 20 additions and 13 deletions

View File

@ -5,7 +5,7 @@
A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code. A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code.
[There are 363 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html) [There are over 363 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
We have a bunch of lint categories to allow you to choose how much Clippy is supposed to ~~annoy~~ help you: We have a bunch of lint categories to allow you to choose how much Clippy is supposed to ~~annoy~~ help you:

View File

@ -17,7 +17,7 @@ pub fn run(update_mode: UpdateMode) {
let internal_lints = Lint::internal_lints(lint_list.clone().into_iter()); let internal_lints = Lint::internal_lints(lint_list.clone().into_iter());
let usable_lints: Vec<Lint> = Lint::usable_lints(lint_list.clone().into_iter()).collect(); let usable_lints: Vec<Lint> = Lint::usable_lints(lint_list.clone().into_iter()).collect();
let usable_lint_count = usable_lints.len(); let usable_lint_count = round_to_fifty(usable_lints.len());
let mut sorted_usable_lints = usable_lints.clone(); let mut sorted_usable_lints = usable_lints.clone();
sorted_usable_lints.sort_by_key(|lint| lint.name.clone()); sorted_usable_lints.sort_by_key(|lint| lint.name.clone());
@ -29,27 +29,26 @@ pub fn run(update_mode: UpdateMode) {
false, false,
update_mode == UpdateMode::Change, update_mode == UpdateMode::Change,
|| { || {
format!( format!("pub static ref ALL_LINTS: Vec<Lint> = vec!{:#?};", sorted_usable_lints)
"pub const ALL_LINTS: [Lint; {}] = {:#?};", .lines()
sorted_usable_lints.len(), .map(ToString::to_string)
sorted_usable_lints .collect::<Vec<_>>()
)
.lines()
.map(ToString::to_string)
.collect::<Vec<_>>()
}, },
) )
.changed; .changed;
file_change |= replace_region_in_file( file_change |= replace_region_in_file(
Path::new("README.md"), Path::new("README.md"),
&format!(r#"\[There are \d+ lints included in this crate!\]\({}\)"#, DOCS_LINK), &format!(
r#"\[There are over \d+ lints included in this crate!\]\({}\)"#,
DOCS_LINK
),
"", "",
true, true,
update_mode == UpdateMode::Change, update_mode == UpdateMode::Change,
|| { || {
vec![format!( vec![format!(
"[There are {} lints included in this crate!]({})", "[There are over {} lints included in this crate!]({})",
usable_lint_count, DOCS_LINK usable_lint_count, DOCS_LINK
)] )]
}, },
@ -161,3 +160,7 @@ pub fn print_lints() {
println!("there are {} lints", usable_lint_count); println!("there are {} lints", usable_lint_count);
} }
fn round_to_fifty(count: usize) -> usize {
count / 50 * 50
}

View File

@ -1,12 +1,15 @@
//! This file is managed by `cargo dev update_lints`. Do not edit. //! This file is managed by `cargo dev update_lints`. Do not edit.
use lazy_static::lazy_static;
pub mod lint; pub mod lint;
pub use lint::Level; pub use lint::Level;
pub use lint::Lint; pub use lint::Lint;
pub use lint::LINT_LEVELS; pub use lint::LINT_LEVELS;
lazy_static! {
// begin lint list, do not remove this comment, its used in `update_lints` // begin lint list, do not remove this comment, its used in `update_lints`
pub const ALL_LINTS: [Lint; 363] = [ pub static ref ALL_LINTS: Vec<Lint> = vec![
Lint { Lint {
name: "absurd_extreme_comparisons", name: "absurd_extreme_comparisons",
group: "correctness", group: "correctness",
@ -2550,3 +2553,4 @@ pub const ALL_LINTS: [Lint; 363] = [
}, },
]; ];
// end lint list, do not remove this comment, its used in `update_lints` // end lint list, do not remove this comment, its used in `update_lints`
}