From 8fc4078d60f0ccf16318fe7fa765fcdd3627fe1f Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 12 Feb 2026 14:02:22 +0000 Subject: chore: fix clippy warnings - Derive Default for config structs instead of manual impl - Fix doc comment formatting in ArchiveConfig::matches - Collapse nested if statement in validate_announcement - Allow too_many_arguments for SyncManager::new --- src/config.rs | 44 +++++--------------------------------------- src/nostr/events.rs | 14 +++++++------- src/sync/mod.rs | 1 + 3 files changed, 13 insertions(+), 46 deletions(-) diff --git a/src/config.rs b/src/config.rs index 271a340..7062187 100644 --- a/src/config.rs +++ b/src/config.rs @@ -109,7 +109,7 @@ impl WhitelistEntry { } /// GRASP-05 Archive mode configuration -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, Default)] pub struct ArchiveConfig { /// Accept all repository announcements (no filtering) /// @@ -146,6 +146,7 @@ impl ArchiveConfig { /// Returns true if: /// - archive_all is true, OR /// - announcement matches any whitelist entry + /// /// Note: grasp_services matching is handled via matches_grasp_services() pub fn matches(&self, npub: &str, identifier: &str) -> bool { if self.archive_all { @@ -171,19 +172,8 @@ impl ArchiveConfig { } } -impl Default for ArchiveConfig { - fn default() -> Self { - Self { - archive_all: false, - whitelist: Vec::new(), - grasp_services: Vec::new(), - read_only: false, - } - } -} - /// Repository whitelist configuration -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, Default)] pub struct RepositoryConfig { /// Whitelist entries for selective repository acceptance /// @@ -207,16 +197,8 @@ impl RepositoryConfig { } } -impl Default for RepositoryConfig { - fn default() -> Self { - Self { - whitelist: Vec::new(), - } - } -} - /// Repository blacklist configuration -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, Default)] pub struct BlacklistConfig { /// Blacklist entries for blocking specific repositories /// @@ -256,16 +238,8 @@ impl BlacklistConfig { } } -impl Default for BlacklistConfig { - fn default() -> Self { - Self { - blacklist: Vec::new(), - } - } -} - /// Event blacklist configuration for blocking events by author npub -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, Default)] pub struct EventBlacklistConfig { /// Blacklisted npubs - events from these authors are rejected /// @@ -292,14 +266,6 @@ impl EventBlacklistConfig { } } -impl Default for EventBlacklistConfig { - fn default() -> Self { - Self { - blacklisted_npubs: Vec::new(), - } - } -} - /// Database backend type for the relay #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Default, ValueEnum)] #[serde(rename_all = "lowercase")] diff --git a/src/nostr/events.rs b/src/nostr/events.rs index 718633e..b9784f7 100644 --- a/src/nostr/events.rs +++ b/src/nostr/events.rs @@ -419,14 +419,14 @@ pub fn validate_announcement( // GRASP-01: Normal mode - accept if announcement lists our service AND matches repository whitelist (if enabled) if lists_service && !archive_config.read_only { // Check repository whitelist if enabled - if repository_config.enabled() { - if !repository_config.matches(&npub, &announcement.identifier) { - return AnnouncementResult::Reject(format!( - "Announcement lists service but does not match repository whitelist. \ + if repository_config.enabled() + && !repository_config.matches(&npub, &announcement.identifier) + { + return AnnouncementResult::Reject(format!( + "Announcement lists service but does not match repository whitelist. \ Repository {}/{} not in whitelist", - npub, announcement.identifier - )); - } + npub, announcement.identifier + )); } return AnnouncementResult::Accept; } diff --git a/src/sync/mod.rs b/src/sync/mod.rs index bc8c428..1ee1872 100644 --- a/src/sync/mod.rs +++ b/src/sync/mod.rs @@ -584,6 +584,7 @@ impl SyncManager { /// * `config` - Configuration for sync settings /// * `data_path` - Path to git data directory (for persistence) /// * `sync_metrics` - Optional pre-registered SyncMetrics (passed from Metrics if metrics are enabled) + #[allow(clippy::too_many_arguments)] pub fn new( bootstrap_relay_url: Option, service_domain: String, -- cgit v1.2.3