appstore: clippy hygiene in signify parsing and tests
- Commit
c18cca9ad9a638f7c255759ee0bd3762587c51a4- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-01 21:56 UTC (4 days ago)
- Parents
c7d89c0
Workspace clippy flagged: Iterator::last on a DoubleEndedIterator in sig_file_signature and its two test copies (folded into rfind with the same predicate, which clippy then suggested over filter+next_back), two unused base64::Engine imports in test modules (STANDARD resolves its methods without them), a &[b'E'] that is simply b"E", a needless &blob(..) borrow into encode, and a useless format! that is blob_line.to_string(). All are same-value, same-order replacements. Verified: cargo clippy -p appstore_signify --all-targets clean, cargo test -p appstore_signify (30+5 passed), fmt clean.
Diff
appstore/src/main/rust/src/lib.rs
diff --git a/appstore/src/main/rust/src/lib.rs b/appstore/src/main/rust/src/lib.rsindex 9d8bfd6149..9f5330869f 100644--- a/appstore/src/main/rust/src/lib.rs+++ b/appstore/src/main/rust/src/lib.rs@@ -146,8 +146,7 @@ pub fn sig_file_signature(text: &str) -> Option<[u8; SIG_LEN]> { let blob = text .lines() .map(str::trim)- .filter(|line| !line.is_empty() && !line.starts_with(UNTRUSTED_COMMENT))- .last()?;+ .rfind(|line| !line.is_empty() && !line.starts_with(UNTRUSTED_COMMENT))?; decode_signature(blob) }
appstore/src/main/rust/src/signify_tests.rs
diff --git a/appstore/src/main/rust/src/signify_tests.rs b/appstore/src/main/rust/src/signify_tests.rsindex f4fdf5e768..81de66da1e 100644--- a/appstore/src/main/rust/src/signify_tests.rs+++ b/appstore/src/main/rust/src/signify_tests.rs@@ -10,7 +10,6 @@ use super::*; use base64::engine::general_purpose::STANDARD;-use base64::Engine as _; use ed25519_dalek::{Signer, SigningKey}; /// The algorithm id real signify writes for ed25519.@@ -92,7 +91,7 @@ fn header_fields_are_extracted_and_short_blobs_rejected() { assert_eq!(algo_id(&key_blob), Some(ALGO)); assert_eq!(key_num(&key_blob), Some(KEY_NUM)); assert_eq!(algo_id(&[]), None);- assert_eq!(algo_id(&[b'E']), None);+ assert_eq!(algo_id(b"E"), None); assert_eq!(key_num(&key_blob[..HEADER_LEN - 1]), None); assert_eq!(key_num(&[]), None); let real = STANDARD.decode(PUBKEY_B64).unwrap();@@ -204,7 +203,7 @@ fn malformed_base64_is_rejected() { let short = STANDARD.encode(blob(ALGO, KEY_NUM, &[0u8; 8])); assert_eq!(decode_pubkey(&short), None); assert_eq!(decode_signature(&short), None);- let almost_key = STANDARD.encode(&blob(ALGO, KEY_NUM, &[0u8; 31]));+ let almost_key = STANDARD.encode(blob(ALGO, KEY_NUM, &[0u8; 31])); assert_eq!(decode_pubkey(&almost_key), None); } @@ -216,7 +215,7 @@ fn sig_file_comment_and_line_variants() { let variants = [ sig_file.clone(), format!("{blob_line}\n"),- format!("{blob_line}"),+ blob_line.to_string(), format!("untrusted comment: verify with fixture.pub\n{blob_line}"), format!(" untrusted comment: indented comment \n {blob_line} \n\n"), format!("\n\nuntrusted comment: x\n\n{blob_line}\n\n\n"),
appstore/src/main/rust/src/tests.rs
diff --git a/appstore/src/main/rust/src/tests.rs b/appstore/src/main/rust/src/tests.rsindex 4bc9da95e8..86257a0415 100644--- a/appstore/src/main/rust/src/tests.rs+++ b/appstore/src/main/rust/src/tests.rs@@ -11,7 +11,6 @@ use super::*; use base64::engine::general_purpose::STANDARD;-use base64::Engine as _; /// The exact bytes that were signed. const REPODATA: &[u8] = include_bytes!("../testvectors/repodata.1.json");@@ -32,8 +31,7 @@ fn signature() -> Vec<u8> { let blob = SIG_FILE .lines() .map(str::trim)- .filter(|l| !l.is_empty() && !l.starts_with("untrusted comment:"))- .last()+ .rfind(|l| !l.is_empty() && !l.starts_with("untrusted comment:")) .unwrap(); STANDARD.decode(blob).unwrap()[10..74].to_vec() }
appstore/src/main/rust/tests/tamper_variants.rs
diff --git a/appstore/src/main/rust/tests/tamper_variants.rs b/appstore/src/main/rust/tests/tamper_variants.rsindex bc7d356687..26561e76ce 100644--- a/appstore/src/main/rust/tests/tamper_variants.rs+++ b/appstore/src/main/rust/tests/tamper_variants.rs@@ -28,8 +28,7 @@ fn signature() -> Vec<u8> { let blob = SIG_FILE .lines() .map(str::trim)- .filter(|l| !l.is_empty() && !l.starts_with("untrusted comment:"))- .last()+ .rfind(|l| !l.is_empty() && !l.starts_with("untrusted comment:")) .unwrap(); STANDARD.decode(blob).unwrap()[10..74].to_vec() }