diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-11 16:53:03 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-11 16:53:03 +0000 |
| commit | 2a9160836bb87fdea3ae891563b0169c68d1c2ab (patch) | |
| tree | 583c890687beaf7f380fc0be131bdf17485f06fa /src/nostr/policy | |
| parent | 52489d3b1a7d79e164b4cc901b53fd06c05ce1b1 (diff) | |
fix: resolve all fmt and clippy warnings
Main lib (src/):
- Add #[allow(dead_code)] for build_info field (stored to prevent Prometheus unregistration)
- Add #[allow(dead_code)] for first_seen field (reserved for future rate limiting)
- Replace .or_insert_with(RelaySyncNeeds::default) with .or_default()
- Replace manual div_ceil implementations with .div_ceil(100)
Test code (tests/):
- Replace .expect(&format!(...)) with .unwrap_or_else(|_| panic!(...))
- Remove needless borrows in fetch_metrics() calls
- Add #[allow(dead_code)] and #[allow(unused_imports)] to test helpers module
grasp-audit:
- Apply cargo fmt to fix formatting
Diffstat (limited to 'src/nostr/policy')
| -rw-r--r-- | src/nostr/policy/announcement.rs | 7 | ||||
| -rw-r--r-- | src/nostr/policy/mod.rs | 3 | ||||
| -rw-r--r-- | src/nostr/policy/pr_event.rs | 2 | ||||
| -rw-r--r-- | src/nostr/policy/related.rs | 7 | ||||
| -rw-r--r-- | src/nostr/policy/state.rs | 7 |
5 files changed, 14 insertions, 12 deletions
diff --git a/src/nostr/policy/announcement.rs b/src/nostr/policy/announcement.rs index 8d30baf..353738b 100644 --- a/src/nostr/policy/announcement.rs +++ b/src/nostr/policy/announcement.rs | |||
| @@ -72,7 +72,10 @@ impl AnnouncementPolicy { | |||
| 72 | 72 | ||
| 73 | /// Create a bare git repository if it doesn't exist | 73 | /// Create a bare git repository if it doesn't exist |
| 74 | /// Path format: <git_data_path>/<npub>/<identifier>.git | 74 | /// Path format: <git_data_path>/<npub>/<identifier>.git |
| 75 | pub fn ensure_bare_repository(&self, announcement: &RepositoryAnnouncement) -> Result<(), String> { | 75 | pub fn ensure_bare_repository( |
| 76 | &self, | ||
| 77 | announcement: &RepositoryAnnouncement, | ||
| 78 | ) -> Result<(), String> { | ||
| 76 | let repo_path = self.ctx.git_data_path.join(announcement.repo_path()); | 79 | let repo_path = self.ctx.git_data_path.join(announcement.repo_path()); |
| 77 | 80 | ||
| 78 | // Check if repository already exists | 81 | // Check if repository already exists |
| @@ -154,4 +157,4 @@ impl AnnouncementPolicy { | |||
| 154 | 157 | ||
| 155 | Ok(false) | 158 | Ok(false) |
| 156 | } | 159 | } |
| 157 | } \ No newline at end of file | 160 | } |
diff --git a/src/nostr/policy/mod.rs b/src/nostr/policy/mod.rs index 6d67394..19db5f6 100644 --- a/src/nostr/policy/mod.rs +++ b/src/nostr/policy/mod.rs | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | /// - `StatePolicy` - State event validation + ref alignment | 5 | /// - `StatePolicy` - State event validation + ref alignment |
| 6 | /// - `PrEventPolicy` - PR/PR Update validation | 6 | /// - `PrEventPolicy` - PR/PR Update validation |
| 7 | /// - `RelatedEventPolicy` - Forward/backward reference checking | 7 | /// - `RelatedEventPolicy` - Forward/backward reference checking |
| 8 | |||
| 9 | mod announcement; | 8 | mod announcement; |
| 10 | mod pr_event; | 9 | mod pr_event; |
| 11 | mod related; | 10 | mod related; |
| @@ -38,4 +37,4 @@ impl PolicyContext { | |||
| 38 | git_data_path: git_data_path.into(), | 37 | git_data_path: git_data_path.into(), |
| 39 | } | 38 | } |
| 40 | } | 39 | } |
| 41 | } \ No newline at end of file | 40 | } |
diff --git a/src/nostr/policy/pr_event.rs b/src/nostr/policy/pr_event.rs index fee9a2a..53da369 100644 --- a/src/nostr/policy/pr_event.rs +++ b/src/nostr/policy/pr_event.rs | |||
| @@ -195,4 +195,4 @@ impl PrEventPolicy { | |||
| 195 | Ok(None) | 195 | Ok(None) |
| 196 | } | 196 | } |
| 197 | } | 197 | } |
| 198 | } \ No newline at end of file | 198 | } |
diff --git a/src/nostr/policy/related.rs b/src/nostr/policy/related.rs index 1937ca7..7ce87db 100644 --- a/src/nostr/policy/related.rs +++ b/src/nostr/policy/related.rs | |||
| @@ -169,10 +169,7 @@ impl RelatedEventPolicy { | |||
| 169 | 169 | ||
| 170 | /// Check if any events exist in database | 170 | /// Check if any events exist in database |
| 171 | /// Returns the first matching event ID found, or None if none match | 171 | /// Returns the first matching event ID found, or None if none match |
| 172 | async fn find_accepted_event( | 172 | async fn find_accepted_event(&self, event_ids: &[EventId]) -> Result<Option<EventId>, String> { |
| 173 | &self, | ||
| 174 | event_ids: &[EventId], | ||
| 175 | ) -> Result<Option<EventId>, String> { | ||
| 176 | if event_ids.is_empty() { | 173 | if event_ids.is_empty() { |
| 177 | return Ok(None); | 174 | return Ok(None); |
| 178 | } | 175 | } |
| @@ -273,4 +270,4 @@ impl RelatedEventPolicy { | |||
| 273 | 270 | ||
| 274 | Ok(false) | 271 | Ok(false) |
| 275 | } | 272 | } |
| 276 | } \ No newline at end of file | 273 | } |
diff --git a/src/nostr/policy/state.rs b/src/nostr/policy/state.rs index 5692bd8..43349e2 100644 --- a/src/nostr/policy/state.rs +++ b/src/nostr/policy/state.rs | |||
| @@ -239,7 +239,10 @@ impl StatePolicy { | |||
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | // Build repository path: <git_data_path>/<owner_npub>/<identifier>.git | 241 | // Build repository path: <git_data_path>/<owner_npub>/<identifier>.git |
| 242 | let repo_path = self.ctx.git_data_path.join(announcement.repo_path().clone()); | 242 | let repo_path = self |
| 243 | .ctx | ||
| 244 | .git_data_path | ||
| 245 | .join(announcement.repo_path().clone()); | ||
| 243 | owner_repos.push((announcement, repo_path)); | 246 | owner_repos.push((announcement, repo_path)); |
| 244 | } | 247 | } |
| 245 | 248 | ||
| @@ -416,4 +419,4 @@ impl StatePolicy { | |||
| 416 | 419 | ||
| 417 | result | 420 | result |
| 418 | } | 421 | } |
| 419 | } \ No newline at end of file | 422 | } |