From d2ac69816567f092fe0d4661723bc43778cb481b Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Mon, 1 Dec 2025 14:31:32 +0000 Subject: fix cargo clippy and fmt warnings --- src/nostr/builder.rs | 14 +++++++------- src/nostr/events.rs | 18 +++++++++--------- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src/nostr') diff --git a/src/nostr/builder.rs b/src/nostr/builder.rs index 8e9926a..97fd17e 100644 --- a/src/nostr/builder.rs +++ b/src/nostr/builder.rs @@ -51,7 +51,7 @@ impl Nip34WritePolicy { /// Create a bare git repository if it doesn't exist /// Path format: //.git fn ensure_bare_repository(&self, announcement: &RepositoryAnnouncement) -> Result<(), String> { - let repo_path = self.git_data_path.join(&announcement.repo_path()); + let repo_path = self.git_data_path.join(announcement.repo_path()); // Check if repository already exists if repo_path.exists() { @@ -69,7 +69,7 @@ impl Nip34WritePolicy { // Initialize bare repository using git command let output = std::process::Command::new("git") - .args(&["init", "--bare", repo_path.to_str().unwrap()]) + .args(["init", "--bare", repo_path.to_str().unwrap()]) .output() .map_err(|e| format!("Failed to execute git init: {}", e))?; @@ -482,7 +482,7 @@ impl Nip34WritePolicy { }; // Build repository path - let repo_path = self.git_data_path.join(&announcement.repo_path()); + let repo_path = self.git_data_path.join(announcement.repo_path()); // Validate the ref match git::validate_nostr_ref(&repo_path, &event_id, &expected_commit) { @@ -631,8 +631,8 @@ impl Nip34WritePolicy { let kind_u16 = event.kind.as_u16(); // Check if this is any kind of replaceable event - let is_regular_replaceable = kind_u16 >= 10000 && kind_u16 < 20000; - let is_parameterized_replaceable = kind_u16 >= 30000 && kind_u16 < 40000; + let is_regular_replaceable = (10000..20000).contains(&kind_u16); + let is_parameterized_replaceable = (30000..40000).contains(&kind_u16); if is_regular_replaceable || is_parameterized_replaceable { // Build the appropriate address format based on event type @@ -669,7 +669,7 @@ impl Nip34WritePolicy { ]; for tag_type in &addressable_tags { - let filter = Filter::new().custom_tag(tag_type.clone(), address.clone()); + let filter = Filter::new().custom_tag(*tag_type, address.clone()); match database.query(filter).await { Ok(events) => { @@ -691,7 +691,7 @@ impl Nip34WritePolicy { ]; for tag_type in &event_id_tags { - let filter = Filter::new().custom_tag(tag_type.clone(), event_id_hex.clone()); + let filter = Filter::new().custom_tag(*tag_type, event_id_hex.clone()); match database.query(filter).await { Ok(events) => { diff --git a/src/nostr/events.rs b/src/nostr/events.rs index 6a62ccd..050bfdd 100644 --- a/src/nostr/events.rs +++ b/src/nostr/events.rs @@ -322,9 +322,9 @@ impl RepositoryState { /// Get the HEAD branch name (without refs/heads/ prefix) pub fn get_head_branch(&self) -> Option<&str> { - self.head.as_ref().and_then(|h| { - h.strip_prefix("refs/heads/") - }) + self.head + .as_ref() + .and_then(|h| h.strip_prefix("refs/heads/")) } /// Check if the HEAD commit is available in the git repository @@ -397,7 +397,7 @@ pub fn validate_state(event: &Event) -> Result<()> { #[cfg(test)] mod tests { use super::*; - use nostr_sdk::{EventBuilder, Keys, Tag}; + use nostr_sdk::{EventBuilder, Keys}; fn create_test_keys() -> Keys { Keys::generate() @@ -618,7 +618,10 @@ mod tests { let announcement = RepositoryAnnouncement::from_event(event).unwrap(); assert_eq!(announcement.maintainers.len(), 1); - assert_eq!(announcement.maintainers[0], maintainer_keys.public_key().to_hex()); + assert_eq!( + announcement.maintainers[0], + maintainer_keys.public_key().to_hex() + ); } #[test] @@ -727,10 +730,7 @@ mod tests { let keys = create_test_keys(); let tags = vec![ - Tag::custom( - nostr_sdk::TagKind::d(), - vec!["test-repo".to_string()], - ), + Tag::custom(nostr_sdk::TagKind::d(), vec!["test-repo".to_string()]), Tag::custom( nostr_sdk::TagKind::Custom("refs/heads/main".into()), vec!["a1b2c3d4".to_string()], -- cgit v1.2.3