Skip to content

Commit

Permalink
dev: Move DOCS_LINK out of lazy_static and reuse it
Browse files Browse the repository at this point in the history
  • Loading branch information
tesuji committed Feb 7, 2020
1 parent f901a61 commit dda13d4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion clippy_dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ lazy_static! {
)
.unwrap();
static ref NL_ESCAPE_RE: Regex = Regex::new(r#"\\\n\s*"#).unwrap();
pub static ref DOCS_LINK: String = "https://rust-lang.github.io/rust-clippy/master/index.html".to_string();
}

pub static DOCS_LINK: &str = "https://rust-lang.github.io/rust-clippy/master/index.html";

/// Lint data parsed from the Clippy source code.
#[derive(Clone, PartialEq, Debug)]
pub struct Lint {
Expand Down
16 changes: 9 additions & 7 deletions clippy_dev/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ fn print_lints() {
println!(
"* [{}]({}#{}) ({})",
lint.name,
clippy_dev::DOCS_LINK.clone(),
clippy_dev::DOCS_LINK,
lint.name,
lint.desc
);
Expand Down Expand Up @@ -191,16 +191,18 @@ fn update_lints(update_mode: UpdateMode) {

file_change |= replace_region_in_file(
Path::new("README.md"),
r#"\[There are \d+ lints included in this crate!\]\(https://rust-lang.github.io/rust-clippy/master/index.html\)"#,
&format!(r#"\[There are \d+ lints included in this crate!\]\({}\)"#, DOCS_LINK),
"",
true,
update_mode == UpdateMode::Change,
|| {
vec![
format!("[There are {} lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)", lint_count)
]
}
).changed;
vec![format!(
"[There are {} lints included in this crate!]({})",
lint_count, DOCS_LINK
)]
},
)
.changed;

file_change |= replace_region_in_file(
Path::new("CHANGELOG.md"),
Expand Down

0 comments on commit dda13d4

Please sign in to comment.