fix: resolve all clippy warnings (-D warnings)

- Box Config in Cli::Serve variant to fix large_enum_variant
- Replace map_or(false, ..) with is_some_and in main.rs
- Remove redundant .to_string() in format! arg in maintainer_reprocessing test
- Replace useless vec! with array literals in sync test files
This commit is contained in:
DanConwayDev
2026-05-15 10:14:07 +00:00
parent 61002d6bb8
commit 1a5350254c
9 changed files with 26 additions and 26 deletions
+6 -7
View File
@@ -1965,14 +1965,13 @@ impl<'a> TestContext<'a> {
.output();
// Step 3: Remove all working directory files for clean state (except .git)
for entry in
fs::read_dir(&clone_path).map_err(|e| anyhow::anyhow!("Failed to read dir: {}", e))?
for entry in fs::read_dir(&clone_path)
.map_err(|e| anyhow::anyhow!("Failed to read dir: {}", e))?
.flatten()
{
if let Ok(entry) = entry {
let path = entry.path();
if path.file_name() != Some(std::ffi::OsStr::new(".git")) {
let _ = fs::remove_file(&path).or_else(|_| fs::remove_dir_all(&path));
}
let path = entry.path();
if path.file_name() != Some(std::ffi::OsStr::new(".git")) {
let _ = fs::remove_file(&path).or_else(|_| fs::remove_dir_all(&path));
}
}
+1 -1
View File
@@ -172,7 +172,7 @@ pub async fn run(args: &CleanupArgs) -> Result<()> {
let npub = announcement.owner_npub();
let identifier = announcement.identifier.clone();
let repo_path = git_data_path.join(&announcement.repo_path());
let repo_path = git_data_path.join(announcement.repo_path());
let (repo_exists, is_empty) = check_repo_empty(&repo_path);
+4 -3
View File
@@ -27,7 +27,7 @@ use ngit_grasp::{
enum Cli {
/// Run the GRASP relay server (default when no subcommand is given).
#[command(name = "serve")]
Serve(Config),
Serve(Box<Config>),
/// Remove kind 30617/30618 events whose bare git repository is empty or missing.
///
@@ -46,7 +46,7 @@ async fn main() -> Result<()> {
// and all relay flags are parsed normally (preserving backward compatibility).
let mut args: Vec<String> = std::env::args().collect();
let known_subcommands = ["serve", "cleanup-empty-repos", "help"];
let has_subcommand = args.get(1).map_or(false, |a| {
let has_subcommand = args.get(1).is_some_and(|a| {
known_subcommands.contains(&a.as_str())
|| matches!(a.as_str(), "-h" | "--help" | "-V" | "--version")
});
@@ -56,7 +56,8 @@ async fn main() -> Result<()> {
match Cli::parse_from(args) {
Cli::CleanupEmptyRepos(cleanup_args) => cleanup_empty_repos::run(&cleanup_args).await,
Cli::Serve(mut config) => {
Cli::Serve(config) => {
let mut config = *config;
// Finish initialising the Config (load relay owner key if not provided).
if config.relay_owner_nsec.is_none() {
config.relay_owner_nsec = Some(Config::load_or_generate_relay_owner_key()?);
+2 -2
View File
@@ -61,7 +61,7 @@ async fn test_discovers_layer3_via_layer2() {
// 4. Set up repository announcement on relay_a with git data
// (purgatory requires git data before announcements are accepted)
let repo_id = "test-repo-discovery";
let domains = vec![relay_a.domain(), relay_b.domain()];
let domains = [relay_a.domain(), relay_b.domain()];
let domain_refs: Vec<&str> = domains.iter().map(|s| s.as_str()).collect();
let (announcement, _git_dir_a) =
@@ -176,7 +176,7 @@ async fn test_relay_discovery_via_announcements_with_historic_sync() {
// 4. Set up repository on relay_a with git data and a Layer 2 issue
// Layer 1: Set up announcement with git data
let domains = vec![relay_a.domain(), relay_b.domain()];
let domains = [relay_a.domain(), relay_b.domain()];
let domain_refs: Vec<&str> = domains.iter().map(|s| s.as_str()).collect();
let repo_id = "test-repo-chain";
+1 -1
View File
@@ -226,7 +226,7 @@ async fn test_history_sync_without_negentropy() {
// Set up announcement on source with git data
// (purgatory requires git data before announcements are accepted)
let domains = vec![source.domain(), syncing_domain.clone()];
let domains = [source.domain(), syncing_domain.clone()];
let domain_refs: Vec<&str> = domains.iter().map(|s| s.as_str()).collect();
let (announcement, _git_dir) = setup_announcement_on_relay(
&source,
+3 -3
View File
@@ -59,7 +59,7 @@ async fn test_live_sync_layer2_events() {
// 4. Create a repository announcement on both relays with git data
// (purgatory requires git data before announcements are accepted)
let repo_id = "test-repo-live-l2";
let domains = vec![relay_a.domain(), relay_b.domain()];
let domains = [relay_a.domain(), relay_b.domain()];
let domain_refs: Vec<&str> = domains.iter().map(|s| s.as_str()).collect();
let (_announcement, _git_dir_a) =
@@ -153,7 +153,7 @@ async fn test_live_sync_layer3_events() {
// 2. Create and send repository announcement to both relays with git data
// (purgatory requires git data before announcements are accepted)
let repo_id = "test-repo-live-l3";
let domains = vec![relay_a.domain(), relay_b.domain()];
let domains = [relay_a.domain(), relay_b.domain()];
let domain_refs: Vec<&str> = domains.iter().map(|s| s.as_str()).collect();
let (_announcement, _git_dir_a) =
@@ -322,7 +322,7 @@ async fn test_live_sync_event_ordering() {
// 2. Create and send repository announcement to both relays with git data
// (purgatory requires git data before announcements are accepted)
let repo_id = "test-repo-ordering";
let domains = vec![relay_a.domain(), relay_b.domain()];
let domains = [relay_a.domain(), relay_b.domain()];
let domain_refs: Vec<&str> = domains.iter().map(|s| s.as_str()).collect();
let (_announcement, _git_dir_a) =
+1 -1
View File
@@ -302,7 +302,7 @@ async fn test_multiple_maintainers_all_reprocessed() {
// tests run in parallel (each test gets its own namespace on relay_a).
let identifier = &format!(
"multi-maintainer-repo-{}",
owner_keys.public_key().to_hex()[..8].to_string()
&owner_keys.public_key().to_hex()[..8]
);
// Step 1: Send each maintainer announcement to relay_a then push git data so all three
+2 -2
View File
@@ -227,7 +227,7 @@ async fn test_startup_sync_event_count() {
// 4. Set up announcement on SOURCE relay with git data
// (purgatory requires git data before announcements are accepted)
let repo_id = "test-repo-metrics";
let domains = vec![source_relay.domain(), syncing_relay.domain()];
let domains = [source_relay.domain(), syncing_relay.domain()];
let domain_refs: Vec<&str> = domains.iter().map(|s| s.as_str()).collect();
let (announcement, _git_dir_source) =
@@ -409,7 +409,7 @@ async fn test_live_sync_event_count() {
// This allows discovery when syncing relay connects
let keys = Keys::generate();
let repo_id = "live-metrics-repo";
let domains = vec![source_relay.domain(), sync_domain.clone()];
let domains = [source_relay.domain(), sync_domain.clone()];
let domain_refs: Vec<&str> = domains.iter().map(|s| s.as_str()).collect();
let (_announcement, _git_dir) =
+6 -6
View File
@@ -58,7 +58,7 @@ async fn test_layer2_sync_with_lowercase_a_tag() {
// 2. Create and send repository announcement to both relays with git data
// (purgatory requires git data before announcements are accepted)
let repo_id = "test-repo-tag-8a";
let domains = vec![relay_a.domain(), relay_b.domain()];
let domains = [relay_a.domain(), relay_b.domain()];
let domain_refs: Vec<&str> = domains.iter().map(|s| s.as_str()).collect();
let (_announcement, _git_dir_a) =
@@ -145,7 +145,7 @@ async fn test_layer2_sync_with_uppercase_a_tag() {
// 2. Create and send repository announcement to both relays with git data
let repo_id = "test-repo-tag-8b";
let domains = vec![relay_a.domain(), relay_b.domain()];
let domains = [relay_a.domain(), relay_b.domain()];
let domain_refs: Vec<&str> = domains.iter().map(|s| s.as_str()).collect();
let (_announcement, _git_dir_a) =
@@ -234,7 +234,7 @@ async fn test_layer2_sync_with_q_tag() {
// 2. Create and send repository announcement to both relays with git data
let repo_id = "test-repo-tag-8c";
let domains = vec![relay_a.domain(), relay_b.domain()];
let domains = [relay_a.domain(), relay_b.domain()];
let domain_refs: Vec<&str> = domains.iter().map(|s| s.as_str()).collect();
let (_announcement, _git_dir_a) =
@@ -329,7 +329,7 @@ async fn test_layer3_sync_with_lowercase_e_tag() {
// 2. Create and send repository announcement to both relays with git data
let repo_id = "test-repo-tag-9a";
let domains = vec![relay_a.domain(), relay_b.domain()];
let domains = [relay_a.domain(), relay_b.domain()];
let domain_refs: Vec<&str> = domains.iter().map(|s| s.as_str()).collect();
let (_announcement, _git_dir_a) =
@@ -436,7 +436,7 @@ async fn test_layer3_sync_with_uppercase_e_tag() {
// 2. Create and send repository announcement to both relays with git data
let repo_id = "test-repo-tag-9b";
let domains = vec![relay_a.domain(), relay_b.domain()];
let domains = [relay_a.domain(), relay_b.domain()];
let domain_refs: Vec<&str> = domains.iter().map(|s| s.as_str()).collect();
let (_announcement, _git_dir_a) =
@@ -547,7 +547,7 @@ async fn test_layer3_sync_with_q_tag() {
// 2. Create and send repository announcement to both relays with git data
let repo_id = "test-repo-tag-9c";
let domains = vec![relay_a.domain(), relay_b.domain()];
let domains = [relay_a.domain(), relay_b.domain()];
let domain_refs: Vec<&str> = domains.iter().map(|s| s.as_str()).collect();
let (_announcement, _git_dir_a) =