From 99a64011272a278d9c35b959893348e9655027a2 Mon Sep 17 00:00:00 2001 From: hyperpolymath <6759885+hyperpolymath@users.noreply.github.com> Date: Sat, 30 May 2026 21:27:50 +0100 Subject: [PATCH] chore(fmt): apply rustfmt drift cleanup (mechanical, no behaviour change) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `cargo fmt --all -- --check` on `main` has been showing diffs in five files for a while. This applies the rustfmt-recommended changes verbatim — purely mechanical line-wrap reformatting, no behavioural changes, no API surface affected. Files touched: - src/assail/analyzer.rs (~7860, ~7931) - src/bridge/classify.rs (~355, ~403, ~439, ~458, ~516) - src/bridge/lockfile.rs (~590, ~1018) - src/bridge/reachability.rs (~258, ~289, ~312, ~382, ~404) - src/main.rs (~2513) Verification: - `cargo fmt --all -- --check` after the edit: clean (exit 0). - `cargo test --lib --no-default-features`: 288 passed, 0 failures. Discovered while running pre-commit checks for the issue #33 polish PR (#88). Filed separately to keep the polish diff focused on its own parser/test changes. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/assail/analyzer.rs | 10 ++++++-- src/bridge/classify.rs | 29 +++++++++++++++------- src/bridge/lockfile.rs | 9 +++++-- src/bridge/reachability.rs | 49 +++++++++++--------------------------- src/main.rs | 5 +--- 5 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/assail/analyzer.rs b/src/assail/analyzer.rs index aa35b7d..0988d46 100644 --- a/src/assail/analyzer.rs +++ b/src/assail/analyzer.rs @@ -7860,7 +7860,9 @@ pub fn safe_get_x() -> Option { fs::write(tmp.path().join("real.rs"), "fn main() {}").unwrap(); let collected = walk_collects(tmp.path()); assert!( - !collected.iter().any(|p| p.to_string_lossy().contains(".yarn/")), + !collected + .iter() + .any(|p| p.to_string_lossy().contains(".yarn/")), ".yarn/ subtree must be skipped" ); assert!( @@ -7931,7 +7933,11 @@ pub fn safe_get_x() -> Option { outputs = { self, nixpkgs }: { }; }"#; let findings = flake_findings(src, "/nonexistent/dir/flake.nix"); - assert_eq!(findings.len(), 1, "unpinned flake.nix must produce one finding"); + assert_eq!( + findings.len(), + 1, + "unpinned flake.nix must produce one finding" + ); assert!( matches!(findings[0].severity, Severity::Low), "missing flake.lock alone is mechanically fixable — must be Low severity, got {:?}", diff --git a/src/bridge/classify.rs b/src/bridge/classify.rs index 041d042..80872e6 100644 --- a/src/bridge/classify.rs +++ b/src/bridge/classify.rs @@ -355,7 +355,8 @@ mod tests { fn test_phantom_declared_recommends_machete_strip() { // file-soup#50 shape: crate declared in Cargo.toml, no `use` site — // strip the manifest entry. - let (cls, rationale, action) = classify(&mock_vuln(false, false), &phantom_declared_evidence()); + let (cls, rationale, action) = + classify(&mock_vuln(false, false), &phantom_declared_evidence()); assert_eq!(cls, Classification::Informational); assert!( action.contains("cargo machete --fix") || action.contains("Strip from Cargo.toml"), @@ -403,10 +404,8 @@ mod tests { fn test_phantom_transitive_unknown_parent_falls_back_gracefully() { // Best-effort parent identification: if Cargo.lock didn't reveal one, // we still produce useful output. - let (cls, rationale, action) = classify( - &mock_vuln(false, false), - &phantom_transitive_evidence(None), - ); + let (cls, rationale, action) = + classify(&mock_vuln(false, false), &phantom_transitive_evidence(None)); assert_eq!(cls, Classification::Informational); assert!( action.contains("an upstream parent dependency"), @@ -439,7 +438,8 @@ mod tests { fn test_phantom_variants_both_classify_informational() { // Three-way classifier output is unchanged from #47. let (cls_decl, _, _) = classify(&mock_vuln(false, false), &phantom_declared_evidence()); - let (cls_trans, _, _) = classify(&mock_vuln(false, false), &phantom_transitive_evidence(None)); + let (cls_trans, _, _) = + classify(&mock_vuln(false, false), &phantom_transitive_evidence(None)); assert_eq!(cls_decl, Classification::Informational); assert_eq!(cls_trans, Classification::Informational); } @@ -458,7 +458,11 @@ mod tests { // a naive strip breaks the build. for name in ["pkg-config", "cc", "bindgen", "cmake", "autocfg", "vcpkg"] { let (cls, _, action) = classify(&vuln_named(name), &phantom_declared_evidence()); - assert_eq!(cls, Classification::Informational, "`{name}` must classify Informational"); + assert_eq!( + cls, + Classification::Informational, + "`{name}` must classify Informational" + ); assert!( action.contains("DO NOT STRIP"), "`{name}` must NOT recommend strip, got: {action}" @@ -516,7 +520,16 @@ mod tests { #[test] fn test_phantom_transitive_gtk_family_via_dioxus_parent() { // Same family check but parent is dioxus-desktop directly. - for name in ["atk", "atk-sys", "gdk", "gdk-sys", "glib", "gtk3-macros", "paste", "fxhash"] { + for name in [ + "atk", + "atk-sys", + "gdk", + "gdk-sys", + "glib", + "gtk3-macros", + "paste", + "fxhash", + ] { let (_, rationale, _) = classify( &vuln_named(name), &phantom_transitive_evidence(Some("dioxus-desktop")), diff --git a/src/bridge/lockfile.rs b/src/bridge/lockfile.rs index a01b86a..46f901c 100644 --- a/src/bridge/lockfile.rs +++ b/src/bridge/lockfile.rs @@ -590,7 +590,9 @@ pub fn collect_cargo_parents( if direct_deps.contains(child) { continue; } - parent.entry(child.clone()).or_insert_with(|| direct_norm.clone()); + parent + .entry(child.clone()) + .or_insert_with(|| direct_norm.clone()); queue.push_back(child.clone()); } } @@ -1018,6 +1020,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" let parents = collect_cargo_parents(dir.path(), &direct); // Both spellings must hit the same normalised entry. - assert_eq!(parents.get("serde-derive").map(String::as_str), Some("serde")); + assert_eq!( + parents.get("serde-derive").map(String::as_str), + Some("serde") + ); } } diff --git a/src/bridge/reachability.rs b/src/bridge/reachability.rs index 4396db0..aac2d62 100644 --- a/src/bridge/reachability.rs +++ b/src/bridge/reachability.rs @@ -258,13 +258,9 @@ mod tests { let mut declared = HashSet::new(); declared.insert("octocrab".to_string()); - let evidence = check_reachability_with_manifest( - tmp.path(), - "octocrab", - &declared, - &HashMap::new(), - ) - .unwrap(); + let evidence = + check_reachability_with_manifest(tmp.path(), "octocrab", &declared, &HashMap::new()) + .unwrap(); assert!(!evidence.is_imported); assert_eq!(evidence.status, ReachabilityStatus::PhantomDeclared); @@ -289,13 +285,8 @@ mod tests { let mut parents = HashMap::new(); parents.insert("rustls".to_string(), "reqwest".to_string()); - let evidence = check_reachability_with_manifest( - tmp.path(), - "rustls", - &declared, - &parents, - ) - .unwrap(); + let evidence = + check_reachability_with_manifest(tmp.path(), "rustls", &declared, &parents).unwrap(); assert!(!evidence.is_imported); assert_eq!(evidence.status, ReachabilityStatus::PhantomTransitive); @@ -312,13 +303,9 @@ mod tests { let mut declared = HashSet::new(); declared.insert("serde".to_string()); - let evidence = check_reachability_with_manifest( - tmp.path(), - "serde", - &declared, - &HashMap::new(), - ) - .unwrap(); + let evidence = + check_reachability_with_manifest(tmp.path(), "serde", &declared, &HashMap::new()) + .unwrap(); assert!(evidence.is_imported); assert_eq!(evidence.status, ReachabilityStatus::Reachable); @@ -382,13 +369,9 @@ octocrab = "0.32" "workspace-member declared dep must be in the direct-deps set" ); - let evidence = check_reachability_with_manifest( - tmp.path(), - "octocrab", - &declared, - &HashMap::new(), - ) - .unwrap(); + let evidence = + check_reachability_with_manifest(tmp.path(), "octocrab", &declared, &HashMap::new()) + .unwrap(); assert_eq!(evidence.status, ReachabilityStatus::PhantomDeclared); } @@ -404,13 +387,9 @@ octocrab = "0.32" let mut declared = HashSet::new(); declared.insert("serde-json".to_string()); - let evidence = check_reachability_with_manifest( - tmp.path(), - "serde_json", - &declared, - &HashMap::new(), - ) - .unwrap(); + let evidence = + check_reachability_with_manifest(tmp.path(), "serde_json", &declared, &HashMap::new()) + .unwrap(); assert_eq!(evidence.status, ReachabilityStatus::PhantomDeclared); } diff --git a/src/main.rs b/src/main.rs index b2cf45f..3d4d0dc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2513,10 +2513,7 @@ fn run_main() -> Result<()> { }) .collect(); positional.sort(); - let description = sub - .get_about() - .map(|s| s.to_string()) - .unwrap_or_default(); + let description = sub.get_about().map(|s| s.to_string()).unwrap_or_default(); modes.insert( name, serde_json::json!({