mirror of
https://github.com/deps-rs/deps.rs.git
synced 2024-11-22 02:16:30 +00:00
Address Clippy
This commit is contained in:
parent
c840d04789
commit
2b45ed16cc
7 changed files with 24 additions and 33 deletions
4
build.rs
4
build.rs
|
@ -26,7 +26,7 @@ fn main() {
|
||||||
|
|
||||||
let hash_path = Path::new(&out_dir).join("style.css.sha1");
|
let hash_path = Path::new(&out_dir).join("style.css.sha1");
|
||||||
let digest = Sha1::digest(style.as_bytes());
|
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
|
// hash and copy the JS file
|
||||||
let js_blob = fs::read("./assets/links.js").unwrap();
|
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_hash_path = Path::new(&out_dir).join("links.js.sha1");
|
||||||
let js_digest = Sha1::digest(&js_blob);
|
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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@ impl GetPopularCrates {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn query(client: reqwest::Client) -> anyhow::Result<Vec<CratePath>> {
|
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 res = client.get(&url).send().await?.error_for_status()?;
|
||||||
|
|
||||||
let summary: SummaryResponse = res.json().await?;
|
let summary: SummaryResponse = res.json().await?;
|
||||||
|
|
|
@ -44,10 +44,7 @@ impl GetPopularRepos {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn query(client: reqwest::Client) -> anyhow::Result<Vec<Repository>> {
|
pub async fn query(client: reqwest::Client) -> anyhow::Result<Vec<Repository>> {
|
||||||
let url = format!(
|
let url = format!("{GITHUB_API_BASE_URI}/search/repositories?q=language:rust&sort=stars");
|
||||||
"{}/search/repositories?q=language:rust&sort=stars",
|
|
||||||
GITHUB_API_BASE_URI
|
|
||||||
);
|
|
||||||
|
|
||||||
let res = client.get(&url).send().await?.error_for_status()?;
|
let res = client.get(&url).send().await?.error_for_status()?;
|
||||||
let summary: GithubSearchResponse = res.json().await?;
|
let summary: GithubSearchResponse = res.json().await?;
|
||||||
|
|
|
@ -224,10 +224,7 @@ mod tests {
|
||||||
let repo = RepoPath::from_parts("github", "deps-rs", "deps.rs").unwrap();
|
let repo = RepoPath::from_parts("github", "deps-rs", "deps.rs").unwrap();
|
||||||
let out = repo.to_usercontent_file_url(RelativePath::new(input));
|
let out = repo.to_usercontent_file_url(RelativePath::new(input));
|
||||||
|
|
||||||
let exp = format!(
|
let exp = format!("https://raw.githubusercontent.com/deps-rs/deps.rs/HEAD/{expected}");
|
||||||
"https://raw.githubusercontent.com/deps-rs/deps.rs/HEAD/{}",
|
|
||||||
expected
|
|
||||||
);
|
|
||||||
assert_eq!(out.to_string(), exp);
|
assert_eq!(out.to_string(), exp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +232,7 @@ mod tests {
|
||||||
let repo = RepoPath::from_parts("gitlab", "deps-rs", "deps.rs").unwrap();
|
let repo = RepoPath::from_parts("gitlab", "deps-rs", "deps.rs").unwrap();
|
||||||
let out = repo.to_usercontent_file_url(RelativePath::new(input));
|
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);
|
assert_eq!(out.to_string(), exp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,10 +240,7 @@ mod tests {
|
||||||
let repo = RepoPath::from_parts("bitbucket", "deps-rs", "deps.rs").unwrap();
|
let repo = RepoPath::from_parts("bitbucket", "deps-rs", "deps.rs").unwrap();
|
||||||
let out = repo.to_usercontent_file_url(RelativePath::new(input));
|
let out = repo.to_usercontent_file_url(RelativePath::new(input));
|
||||||
|
|
||||||
let exp = format!(
|
let exp = format!("https://bitbucket.org/deps-rs/deps.rs/raw/HEAD/{expected}");
|
||||||
"https://bitbucket.org/deps-rs/deps.rs/raw/HEAD/{}",
|
|
||||||
expected
|
|
||||||
);
|
|
||||||
assert_eq!(out.to_string(), exp);
|
assert_eq!(out.to_string(), exp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,7 +248,7 @@ mod tests {
|
||||||
let repo = RepoPath::from_parts("codeberg", "deps-rs", "deps.rs").unwrap();
|
let repo = RepoPath::from_parts("codeberg", "deps-rs", "deps.rs").unwrap();
|
||||||
let out = repo.to_usercontent_file_url(RelativePath::new(input));
|
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);
|
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 repo = RepoPath::from_parts("gitea/gitea.com", "deps-rs", "deps.rs").unwrap();
|
||||||
let out = repo.to_usercontent_file_url(RelativePath::new(input));
|
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);
|
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 repo = RepoPath::from_parts("gitea/example.com/git", "deps-rs", "deps.rs").unwrap();
|
||||||
let out = repo.to_usercontent_file_url(RelativePath::new(input));
|
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);
|
assert_eq!(out.to_string(), exp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ pub fn badge(
|
||||||
if outdated > 0 {
|
if outdated > 0 {
|
||||||
BadgeOptions {
|
BadgeOptions {
|
||||||
subject,
|
subject,
|
||||||
status: format!("{} of {} outdated", outdated, total),
|
status: format!("{outdated} of {total} outdated"),
|
||||||
color: "#dfb317".into(),
|
color: "#dfb317".into(),
|
||||||
style: badge_knobs.style,
|
style: badge_knobs.style,
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ fn render_html<B: Render>(title: &str, body: B) -> Response<Body> {
|
||||||
head {
|
head {
|
||||||
meta charset="utf-8";
|
meta charset="utf-8";
|
||||||
meta name="viewport" content="width=device-width, initial-scale=1";
|
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="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=(STATIC_STYLE_CSS_PATH);
|
||||||
link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Fira+Sans:400,500,600";
|
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 {
|
@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)")) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,14 +61,14 @@ fn dependency_table(title: &str, deps: &IndexMap<CrateName, AnalyzedDependency>)
|
||||||
h3 class="title is-4" { (title) }
|
h3 class="title is-4" { (title) }
|
||||||
p class="subtitle is-5" {
|
p class="subtitle is-5" {
|
||||||
(match (count_outdated, count_always_insecure, count_insecure - count_always_insecure) {
|
(match (count_outdated, count_always_insecure, count_insecure - count_always_insecure) {
|
||||||
(0, 0, 0) => format!("({} total, all up-to-date)", count_total),
|
(0, 0, 0) => format!("({count_total} total, all up-to-date)"),
|
||||||
(0, 0, c) => format!("({} total, {} possibly insecure)", count_total, c),
|
(0, 0, c) => format!("({count_total} total, {c} possibly insecure)"),
|
||||||
(_, 0, 0) => format!("({} total, {} outdated)", count_total, count_outdated),
|
(_, 0, 0) => format!("({count_total} total, {count_outdated} outdated)"),
|
||||||
(0, _, 0) => format!("({} total, {} insecure)", count_total, count_always_insecure),
|
(0, _, 0) => format!("({count_total} total, {count_always_insecure} insecure)"),
|
||||||
(0, _, c) => format!("({} total, {} insecure, {} possibly insecure)", count_total, count_always_insecure, c),
|
(0, _, c) => format!("({count_total} total, {count_always_insecure} insecure, {c} possibly insecure)"),
|
||||||
(_, 0, c) => format!("({} total, {} outdated, {} possibly insecure)", count_total, count_outdated, c),
|
(_, 0, c) => format!("({count_total} total, {count_outdated} outdated, {c} possibly insecure)"),
|
||||||
(_, _, 0) => format!("({} total, {} outdated, {} insecure)", count_total, count_outdated, count_always_insecure),
|
(_, _, 0) => format!("({count_total} total, {count_outdated} outdated, {count_always_insecure} insecure)"),
|
||||||
(_, _, c) => format!("({} total, {} outdated, {} insecure, {} possibly insecure)", count_total, count_outdated, count_always_insecure, c),
|
(_, _, c) => format!("({count_total} total, {count_outdated} outdated, {count_always_insecure} insecure, {c} possibly insecure)"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,7 +385,7 @@ fn render_success(
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
html! {
|
html! {
|
||||||
section class=(format!("hero {}", hero_class)) {
|
section class=(format!("hero {hero_class}")) {
|
||||||
div class="hero-head" { (super::render_navbar()) }
|
div class="hero-head" { (super::render_navbar()) }
|
||||||
div class="hero-body" {
|
div class="hero-body" {
|
||||||
div class="container" {
|
div class="container" {
|
||||||
|
@ -406,9 +406,9 @@ fn render_success(
|
||||||
div class="container" {
|
div class="container" {
|
||||||
pre class="is-size-7" {
|
pre class="is-size-7" {
|
||||||
@if extra_config.path.is_some() {
|
@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 {
|
} @else {
|
||||||
(format!("[![dependency status]({}/status.svg)]({})", status_base_url, status_base_url))
|
(format!("[![dependency status]({status_base_url}/status.svg)]({status_base_url})"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue