From 5852a685c1c8a567f1940e21d10d046f2de1e63d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 23 Oct 2026 07:43:32 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A8=20lint:=20merged=20tests=20drop=20?= =?UTF-8?q?needless=20borrows=20and=20name=20their=20complex=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/forge-web/src/api/statuses.rs | 3 ++- crates/forge-web/src/git_auth.rs | 3 ++- crates/forge-web/src/pages/browse_tests.rs | 26 +++++++++++----------- crates/forge-web/src/pages/forgot.rs | 24 ++++++++++---------- crates/forge-web/src/pages/new_repo.rs | 3 ++- crates/forge-web/src/signatures.rs | 3 ++- crates/forge-web/src/views/heatmap.rs | 3 ++- 7 files changed, 35 insertions(+), 30 deletions(-) diff --git a/crates/forge-web/src/api/statuses.rs b/crates/forge-web/src/api/statuses.rs index bc5fb76..327aa79 100644 --- a/crates/forge-web/src/api/statuses.rs +++ b/crates/forge-web/src/api/statuses.rs @@ -361,7 +361,8 @@ mod tests { let bad_sha = report_uri("abc123"); let missing = report_uri(&"0".repeat(40)); // (case, uri, auth, cookie, body, expected status, expects a JSON error body) - let cases: [(&str, &str, Option<&str>, Option<&str>, Option<&str>, u16, bool); 10] = [ + type Case<'a> = (&'a str, &'a str, Option<&'a str>, Option<&'a str>, Option<&'a str>, u16, bool); + let cases: [Case<'_>; 10] = [ ("read-only token", report.as_str(), Some(reader.as_str()), None, Some(SUCCESS), 403, true), ("anonymous", report.as_str(), None, None, Some(SUCCESS), 401, true), ("bad token", report.as_str(), Some("Bearer forge_not_a_real_token"), None, Some(SUCCESS), 401, false), diff --git a/crates/forge-web/src/git_auth.rs b/crates/forge-web/src/git_auth.rs index 2ae83ac..ca31939 100644 --- a/crates/forge-web/src/git_auth.rs +++ b/crates/forge-web/src/git_auth.rs @@ -102,7 +102,8 @@ mod tests { fn parse_basic_auth_cases() { // One labelled table: each case keeps its own input and expected result. let t = BASE64_STANDARD.encode("tahinli:t"); - let cases: Vec<(&str, String, Option<(&str, &str)>)> = vec![ + type Case<'a> = (&'a str, String, Option<(&'a str, &'a str)>); + let cases: Vec> = vec![ ( "user and token", basic("tahinli:forge_abc"), diff --git a/crates/forge-web/src/pages/browse_tests.rs b/crates/forge-web/src/pages/browse_tests.rs index e54936e..db90352 100644 --- a/crates/forge-web/src/pages/browse_tests.rs +++ b/crates/forge-web/src/pages/browse_tests.rs @@ -73,7 +73,7 @@ fn whitespace_commit(fx: &Fixture) -> String { /// The commit toolbar, and the whitespace toggle that hides whitespace-only files. async fn scenario_whitespace_toolbar(fx: &Fixture) { - let oid = whitespace_commit(&fx); + let oid = whitespace_commit(fx); let base = format!("/{OWNER}/{REPO}/commit/{oid}"); let (status, _, body) = get(&fx.router, &base).await; @@ -275,7 +275,7 @@ async fn scenario_branches(fx: &Fixture, cookie: &str) { ); let page = format!("/{OWNER}/{REPO}/branches"); - let (status, _, html) = send(&fx.router, "GET", &page, Some(&cookie), &[]).await; + let (status, _, html) = send(&fx.router, "GET", &page, Some(cookie), &[]).await; assert_eq!(status, 200); // feature is 1 ahead of and 54 behind main (the root is its base, main has 54 more commits). assert!(html.contains("1 ahead, 54 behind"), "{html}"); @@ -292,7 +292,7 @@ async fn scenario_branches(fx: &Fixture, cookie: &str) { &fx.router, "POST", &page, - Some(&cookie), + Some(cookie), &[("csrf", CSRF), ("name", "topic/one"), ("from", "feature")], ) .await; @@ -314,7 +314,7 @@ async fn scenario_branches(fx: &Fixture, cookie: &str) { &fx.router, "POST", &page, - Some(&cookie), + Some(cookie), &[("csrf", CSRF), ("name", name), ("from", from)], ) .await; @@ -338,7 +338,7 @@ async fn scenario_branches(fx: &Fixture, cookie: &str) { &fx.router, "POST", &page, - Some(&cookie), + Some(cookie), &[("csrf", "wrong"), ("name", "x"), ("from", "main")], ) .await; @@ -350,7 +350,7 @@ async fn scenario_branches(fx: &Fixture, cookie: &str) { &fx.router, "POST", &delete, - Some(&cookie), + Some(cookie), &[("csrf", CSRF), ("name", "topic/one"), ("oid", &fx.root)], ) .await; @@ -360,7 +360,7 @@ async fn scenario_branches(fx: &Fixture, cookie: &str) { &fx.router, "POST", &delete, - Some(&cookie), + Some(cookie), &[("csrf", CSRF), ("name", "topic/one"), ("oid", &feature_tip)], ) .await; @@ -374,7 +374,7 @@ async fn scenario_branches(fx: &Fixture, cookie: &str) { &fx.router, "POST", &delete, - Some(&cookie), + Some(cookie), &[("csrf", CSRF), ("name", "main"), ("oid", &main_tip)], ) .await; @@ -402,7 +402,7 @@ async fn scenario_protection(fx: &Fixture, cookie: &str) { &fx.router, "POST", &delete, - Some(&cookie), + Some(cookie), &[("csrf", CSRF), ("name", "release/1"), ("oid", &tip)], ) .await; @@ -412,7 +412,7 @@ async fn scenario_protection(fx: &Fixture, cookie: &str) { &fx.router, "POST", &delete, - Some(&cookie), + Some(cookie), &[("csrf", CSRF), ("name", "scratch"), ("oid", &tip)], ) .await; @@ -428,7 +428,7 @@ async fn scenario_default_branch(fx: &Fixture, cookie: &str) { &fx.router, "POST", &settings, - Some(&cookie), + Some(cookie), &[ ("csrf", CSRF), ("description", "demo"), @@ -452,7 +452,7 @@ async fn scenario_default_branch(fx: &Fixture, cookie: &str) { &fx.router, "POST", &settings, - Some(&cookie), + Some(cookie), &[ ("csrf", CSRF), ("description", "demo"), @@ -474,7 +474,7 @@ async fn scenario_default_branch(fx: &Fixture, cookie: &str) { &fx.router, "GET", &format!("/{OWNER}/{REPO}/settings"), - Some(&cookie), + Some(cookie), &[], ) .await; diff --git a/crates/forge-web/src/pages/forgot.rs b/crates/forge-web/src/pages/forgot.rs index b8adde9..9c3e93a 100644 --- a/crates/forge-web/src/pages/forgot.rs +++ b/crates/forge-web/src/pages/forgot.rs @@ -291,10 +291,10 @@ mod tests { .await .unwrap(); for address in ["nobody@example.com", "frank@example.com"] { - let (cookie, precsrf) = precsrf_for(&router, "/forgot").await; + let (cookie, precsrf) = precsrf_for(router, "/forgot").await; let form = format!("precsrf={precsrf}&email={}", address.replace('@', "%40")); let (status, _, html) = - send(&router, "POST", "/forgot", Some(&cookie), Some(&form)).await; + send(router, "POST", "/forgot", Some(&cookie), Some(&form)).await; assert_eq!(status, 200, "{address}"); assert!(html.contains("a reset link is on its way"), "{address}"); } @@ -326,21 +326,21 @@ mod tests { .is_some() ); - let (cookie, precsrf) = precsrf_for(&router, "/forgot").await; + let (cookie, precsrf) = precsrf_for(router, "/forgot").await; let form = format!("precsrf={precsrf}&email=gina%40example.com"); - let (status, _, _) = send(&router, "POST", "/forgot", Some(&cookie), Some(&form)).await; + let (status, _, _) = send(router, "POST", "/forgot", Some(&cookie), Some(&form)).await; assert_eq!(status, 200); - let body = wait_for_mail(&state, "/reset/").await; + let body = wait_for_mail(state, "/reset/").await; let path = link_in(&body, "/reset/"); - let (status, _, html) = send(&router, "GET", &path, None, None).await; + let (status, _, html) = send(router, "GET", &path, None, None).await; assert_eq!(status, 200); assert!(html.contains("Set a new password")); - let (cookie, precsrf) = precsrf_for(&router, &path).await; + let (cookie, precsrf) = precsrf_for(router, &path).await; let form = format!("precsrf={precsrf}&password=brand-new-password-1&confirm=brand-new-password-1"); - let (status, _, html) = send(&router, "POST", &path, Some(&cookie), Some(&form)).await; + let (status, _, html) = send(router, "POST", &path, Some(&cookie), Some(&form)).await; assert_eq!(status, 200); assert!(html.contains("Your password is changed")); @@ -352,10 +352,10 @@ mod tests { ); // The same link is spent now. - let (cookie, precsrf) = precsrf_for(&router, &path).await; + let (cookie, precsrf) = precsrf_for(router, &path).await; let form = format!("precsrf={precsrf}&password=another-password-22&confirm=another-password-22"); - let (status, _, html) = send(&router, "POST", &path, Some(&cookie), Some(&form)).await; + let (status, _, html) = send(router, "POST", &path, Some(&cookie), Some(&form)).await; assert_eq!(status, 200); assert!(html.contains("This reset link is invalid")); } @@ -376,9 +376,9 @@ mod tests { let token = state.store.create_reset_token(&user.id).await.unwrap(); let path = format!("/reset/{token}"); - let (cookie, precsrf) = precsrf_for(&router, &path).await; + let (cookie, precsrf) = precsrf_for(router, &path).await; let form = format!("precsrf={precsrf}&password=short&confirm=short"); - let (status, _, html) = send(&router, "POST", &path, Some(&cookie), Some(&form)).await; + let (status, _, html) = send(router, "POST", &path, Some(&cookie), Some(&form)).await; assert_eq!(status, 200); assert!( html.contains("Set a new password"), diff --git a/crates/forge-web/src/pages/new_repo.rs b/crates/forge-web/src/pages/new_repo.rs index a3971e9..ca0c09d 100644 --- a/crates/forge-web/src/pages/new_repo.rs +++ b/crates/forge-web/src/pages/new_repo.rs @@ -498,7 +498,8 @@ mod tests { #[tokio::test] async fn default_labels_are_added_only_when_checked() { let site = site().await; - let cases: [(&str, &[(&str, &str)], usize); 2] = [ + type Case<'a> = (&'a str, &'a [(&'a str, &'a str)], usize); + let cases: [Case<'_>; 2] = [ ("checked", &[("default_labels", "on")], 9), ("unchecked", &[], 0), ]; diff --git a/crates/forge-web/src/signatures.rs b/crates/forge-web/src/signatures.rs index b010b25..3967ba6 100644 --- a/crates/forge-web/src/signatures.rs +++ b/crates/forge-web/src/signatures.rs @@ -793,7 +793,8 @@ mod tests { #[test] fn key_listing_parses_one_key_or_rejects() { // (name, colon listing, expected Some((primary fingerprint, emails)) or None for rejection) - let cases: Vec<(&str, &str, Option<(&str, Vec<&str>)>)> = vec![ + type Case<'a> = (&'a str, &'a str, Option<(&'a str, Vec<&'a str>)>); + let cases: Vec> = vec![ ( "primary fingerprint and emails", "pub:u:255:22:ABCDEF0123456789ABCDEF0123456789ABCDEF01:1700000000::::::23::0:\n\ diff --git a/crates/forge-web/src/views/heatmap.rs b/crates/forge-web/src/views/heatmap.rs index 0ba1af2..3757796 100644 --- a/crates/forge-web/src/views/heatmap.rs +++ b/crates/forge-web/src/views/heatmap.rs @@ -354,7 +354,8 @@ mod tests { #[test] fn a_gap_or_an_old_run_ends_the_current_streak() { // (case, counts, current streak, longest streak) - let cases: [(&str, &[(&str, u32)], u64, u64); 2] = [ + type Case<'a> = (&'a str, &'a [(&'a str, u32)], u64, u64); + let cases: [Case<'_>; 2] = [ ( "old run", &[("2026-10-01", 3), ("2026-10-02", 3)],