Address Clippy

This commit is contained in:
Rob Ede 2023-01-31 08:40:34 -05:00
parent c840d04789
commit 2b45ed16cc
No known key found for this signature in database
GPG key ID: 97C636207D3EF933
7 changed files with 24 additions and 33 deletions

View file

@ -26,7 +26,7 @@ fn main() {
let hash_path = Path::new(&out_dir).join("style.css.sha1");
let digest = Sha1::digest(style.as_bytes());
fs::write(hash_path, format!("{:x}", digest)).unwrap();
fs::write(hash_path, format!("{digest:x}")).unwrap();
// hash and copy the JS file
let js_blob = fs::read("./assets/links.js").unwrap();
@ -35,5 +35,5 @@ fn main() {
let js_hash_path = Path::new(&out_dir).join("links.js.sha1");
let js_digest = Sha1::digest(&js_blob);
fs::write(js_hash_path, format!("{:x}", js_digest)).unwrap();
fs::write(js_hash_path, format!("{js_digest:x}")).unwrap();
}

View file

@ -132,7 +132,7 @@ impl GetPopularCrates {
}
pub async fn query(client: reqwest::Client) -> anyhow::Result<Vec<CratePath>> {
let url = format!("{}/summary", CRATES_API_BASE_URI);
let url = format!("{CRATES_API_BASE_URI}/summary");
let res = client.get(&url).send().await?.error_for_status()?;
let summary: SummaryResponse = res.json().await?;

View file

@ -44,10 +44,7 @@ impl GetPopularRepos {
}
pub async fn query(client: reqwest::Client) -> anyhow::Result<Vec<Repository>> {
let url = format!(
"{}/search/repositories?q=language:rust&sort=stars",
GITHUB_API_BASE_URI
);
let url = format!("{GITHUB_API_BASE_URI}/search/repositories?q=language:rust&sort=stars");
let res = client.get(&url).send().await?.error_for_status()?;
let summary: GithubSearchResponse = res.json().await?;

View file

@ -224,10 +224,7 @@ mod tests {
let repo = RepoPath::from_parts("github", "deps-rs", "deps.rs").unwrap();
let out = repo.to_usercontent_file_url(RelativePath::new(input));
let exp = format!(
"https://raw.githubusercontent.com/deps-rs/deps.rs/HEAD/{}",
expected
);
let exp = format!("https://raw.githubusercontent.com/deps-rs/deps.rs/HEAD/{expected}");
assert_eq!(out.to_string(), exp);
}
@ -235,7 +232,7 @@ mod tests {
let repo = RepoPath::from_parts("gitlab", "deps-rs", "deps.rs").unwrap();
let out = repo.to_usercontent_file_url(RelativePath::new(input));
let exp = format!("https://gitlab.com/deps-rs/deps.rs/raw/HEAD/{}", expected);
let exp = format!("https://gitlab.com/deps-rs/deps.rs/raw/HEAD/{expected}");
assert_eq!(out.to_string(), exp);
}
@ -243,10 +240,7 @@ mod tests {
let repo = RepoPath::from_parts("bitbucket", "deps-rs", "deps.rs").unwrap();
let out = repo.to_usercontent_file_url(RelativePath::new(input));
let exp = format!(
"https://bitbucket.org/deps-rs/deps.rs/raw/HEAD/{}",
expected
);
let exp = format!("https://bitbucket.org/deps-rs/deps.rs/raw/HEAD/{expected}");
assert_eq!(out.to_string(), exp);
}
@ -254,7 +248,7 @@ mod tests {
let repo = RepoPath::from_parts("codeberg", "deps-rs", "deps.rs").unwrap();
let out = repo.to_usercontent_file_url(RelativePath::new(input));
let exp = format!("https://codeberg.org/deps-rs/deps.rs/raw/{}", expected);
let exp = format!("https://codeberg.org/deps-rs/deps.rs/raw/{expected}");
assert_eq!(out.to_string(), exp);
}
@ -262,7 +256,7 @@ mod tests {
let repo = RepoPath::from_parts("gitea/gitea.com", "deps-rs", "deps.rs").unwrap();
let out = repo.to_usercontent_file_url(RelativePath::new(input));
let exp = format!("https://gitea.com/deps-rs/deps.rs/raw/{}", expected);
let exp = format!("https://gitea.com/deps-rs/deps.rs/raw/{expected}");
assert_eq!(out.to_string(), exp);
}
@ -270,7 +264,7 @@ mod tests {
let repo = RepoPath::from_parts("gitea/example.com/git", "deps-rs", "deps.rs").unwrap();
let out = repo.to_usercontent_file_url(RelativePath::new(input));
let exp = format!("https://example.com/git/deps-rs/deps.rs/raw/{}", expected);
let exp = format!("https://example.com/git/deps-rs/deps.rs/raw/{expected}");
assert_eq!(out.to_string(), exp);
}
}

View file

@ -31,7 +31,7 @@ pub fn badge(
if outdated > 0 {
BadgeOptions {
subject,
status: format!("{} of {} outdated", outdated, total),
status: format!("{outdated} of {total} outdated"),
color: "#dfb317".into(),
style: badge_knobs.style,
}

View file

@ -18,7 +18,7 @@ fn render_html<B: Render>(title: &str, body: B) -> Response<Body> {
head {
meta charset="utf-8";
meta name="viewport" content="width=device-width, initial-scale=1";
title { (format!("{} - Deps.rs", title)) }
title { (format!("{title} - Deps.rs")) }
link rel="icon" type="image/svg+xml" href="/static/logo.svg";
link rel="stylesheet" type="text/css" href=(STATIC_STYLE_CSS_PATH);
link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Fira+Sans:400,500,600";
@ -67,7 +67,7 @@ fn render_footer(duration: Option<Duration>) -> Markup {
"."
}
@if let Some(millis) = duration_millis {
p class="has-text-grey is-size-7" { (format!("(rendered in {} ms)", millis)) }
p class="has-text-grey is-size-7" { (format!("(rendered in {millis} ms)")) }
}
}
}

View file

@ -61,14 +61,14 @@ fn dependency_table(title: &str, deps: &IndexMap<CrateName, AnalyzedDependency>)
h3 class="title is-4" { (title) }
p class="subtitle is-5" {
(match (count_outdated, count_always_insecure, count_insecure - count_always_insecure) {
(0, 0, 0) => format!("({} total, all up-to-date)", count_total),
(0, 0, c) => format!("({} total, {} possibly insecure)", count_total, c),
(_, 0, 0) => format!("({} total, {} outdated)", count_total, count_outdated),
(0, _, 0) => format!("({} total, {} insecure)", count_total, count_always_insecure),
(0, _, c) => format!("({} total, {} insecure, {} possibly insecure)", count_total, count_always_insecure, c),
(_, 0, c) => format!("({} total, {} outdated, {} possibly insecure)", count_total, count_outdated, c),
(_, _, 0) => format!("({} total, {} outdated, {} insecure)", count_total, count_outdated, count_always_insecure),
(_, _, c) => format!("({} total, {} outdated, {} insecure, {} possibly insecure)", count_total, count_outdated, count_always_insecure, c),
(0, 0, 0) => format!("({count_total} total, all up-to-date)"),
(0, 0, c) => format!("({count_total} total, {c} possibly insecure)"),
(_, 0, 0) => format!("({count_total} total, {count_outdated} outdated)"),
(0, _, 0) => format!("({count_total} total, {count_always_insecure} insecure)"),
(0, _, c) => format!("({count_total} total, {count_always_insecure} insecure, {c} possibly insecure)"),
(_, 0, c) => format!("({count_total} total, {count_outdated} outdated, {c} possibly insecure)"),
(_, _, 0) => format!("({count_total} total, {count_outdated} outdated, {count_always_insecure} insecure)"),
(_, _, c) => format!("({count_total} total, {count_outdated} outdated, {count_always_insecure} insecure, {c} possibly insecure)"),
})
}
@ -385,7 +385,7 @@ fn render_success(
.unwrap();
html! {
section class=(format!("hero {}", hero_class)) {
section class=(format!("hero {hero_class}")) {
div class="hero-head" { (super::render_navbar()) }
div class="hero-body" {
div class="container" {
@ -406,9 +406,9 @@ fn render_success(
div class="container" {
pre class="is-size-7" {
@if extra_config.path.is_some() {
(format!("[![dependency status]({}/status.svg?{opt})]({}?{opt})", status_base_url, status_base_url, opt = options))
(format!("[![dependency status]({status_base_url}/status.svg?{options})]({status_base_url}?{options})"))
} @else {
(format!("[![dependency status]({}/status.svg)]({})", status_base_url, status_base_url))
(format!("[![dependency status]({status_base_url}/status.svg)]({status_base_url})"))
}
}
}