RIIR update_lints: Replace lint count in README.md

This allows the usage of `util/dev update_lints` which will write the
new lint_count to the `README.md`.
This commit is contained in:
Philipp Hansch
2018-10-16 08:00:31 +02:00
parent af441b5b07
commit 956987f43e
2 changed files with 139 additions and 0 deletions

View File

@@ -32,6 +32,8 @@ fn main() {
if let Some(matches) = matches.subcommand_matches("update_lints") {
if matches.is_present("print-only") {
print_lints();
} else {
update_lints();
}
}
}
@@ -55,3 +57,21 @@ fn print_lints() {
println!("there are {} lints", lint_count);
}
fn update_lints() {
let lint_list = gather_all();
let usable_lints: Vec<Lint> = Lint::usable_lints(lint_list).collect();
let lint_count = usable_lints.len();
replace_region_in_file(
"../README.md",
r#"\[There are \d+ lints included in this crate!\]\(https://rust-lang-nursery.github.io/rust-clippy/master/index.html\)"#,
"",
true,
|| {
vec![
format!("[There are {} lints included in this crate!](https://rust-lang-nursery.github.io/rust-clippy/master/index.html)", lint_count)
]
}
);
}