Skip to content

Commit 28ccef7

Browse files
committed
fix clippy
1 parent d42f8dd commit 28ccef7

File tree

4 files changed

+32
-37
lines changed

4 files changed

+32
-37
lines changed

rust-docs-mcp/src/cache/downloader.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,11 @@ impl CrateDownloader {
215215
.context("Failed to write to temporary file")?;
216216

217217
// Report progress if callback provided and total size known
218-
if let Some(ref callback) = progress_callback {
219-
if total_bytes > 0 {
218+
if let Some(ref callback) = progress_callback
219+
&& total_bytes > 0 {
220220
let percent = ((downloaded_bytes * 100) / total_bytes).min(100) as u8;
221221
callback(percent);
222222
}
223-
}
224223
}
225224

226225
// Extract the crate

rust-docs-mcp/src/cache/task_formatter.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,30 @@ fn format_timestamp(time: SystemTime) -> String {
1717
/// Format duration in seconds to human-readable string
1818
fn format_duration(secs: u64) -> String {
1919
if secs < 60 {
20-
format!("{}s", secs)
20+
format!("{secs}s")
2121
} else if secs < 3600 {
2222
let mins = secs / 60;
2323
let remaining_secs = secs % 60;
2424
if remaining_secs == 0 {
25-
format!("{}m", mins)
25+
format!("{mins}m")
2626
} else {
27-
format!("{}m {}s", mins, remaining_secs)
27+
format!("{mins}m {remaining_secs}s")
2828
}
2929
} else {
3030
let hours = secs / 3600;
3131
let remaining_mins = (secs % 3600) / 60;
3232
if remaining_mins == 0 {
33-
format!("{}h", hours)
33+
format!("{hours}h")
3434
} else {
35-
format!("{}h {}m", hours, remaining_mins)
35+
format!("{hours}h {remaining_mins}m")
3636
}
3737
}
3838
}
3939

4040
/// Format the cache_crate tool result when a task is started
4141
pub fn format_task_started(task: &CachingTask) -> String {
4242
let source_info = if let Some(details) = &task.source_details {
43-
format!(" ({})", details)
43+
format!(" ({details})")
4444
} else {
4545
String::new()
4646
};
@@ -70,7 +70,7 @@ The caching operation is running in the background.
7070
/// Format a single task with full details
7171
pub fn format_single_task(task: &CachingTask) -> String {
7272
let source_info = if let Some(details) = &task.source_details {
73-
format!(" ({})", details)
73+
format!(" ({details})")
7474
} else {
7575
String::new()
7676
};
@@ -83,9 +83,9 @@ pub fn format_single_task(task: &CachingTask) -> String {
8383
let desc = task
8484
.step_description
8585
.as_ref()
86-
.map(|d| format!(": {}", d))
86+
.map(|d| format!(": {d}"))
8787
.unwrap_or_default();
88-
format!("\n**Step**: {} of {}{}", step, total, desc)
88+
format!("\n**Step**: {step} of {total}{desc}")
8989
} else {
9090
String::new()
9191
};
@@ -159,7 +159,7 @@ The crate has been successfully cached and documentation is available. You can n
159159
let error_msg = task
160160
.error
161161
.as_ref()
162-
.map(|e| format!("```\n{}\n```", e))
162+
.map(|e| format!("```\n{e}\n```"))
163163
.unwrap_or_else(|| "Unknown error".to_string());
164164

165165
format!(
@@ -271,7 +271,7 @@ pub fn format_task_list(tasks: Vec<CachingTask>) -> String {
271271
// Build summary
272272
let mut output = String::from("# Caching Operations\n\n");
273273
output.push_str("## Summary\n");
274-
output.push_str(&format!("- **Total Operations**: {}\n", total));
274+
output.push_str(&format!("- **Total Operations**: {total}\n"));
275275
if !in_progress.is_empty() {
276276
output.push_str(&format!("- **In Progress**: {}\n", in_progress.len()));
277277
}
@@ -353,7 +353,7 @@ pub fn format_task_list(tasks: Vec<CachingTask>) -> String {
353353
/// Format a concise task summary for list view
354354
fn format_task_summary(task: &CachingTask) -> String {
355355
let source_info = if let Some(details) = &task.source_details {
356-
format!(" ({})", details)
356+
format!(" ({details})")
357357
} else {
358358
String::new()
359359
};
@@ -378,9 +378,9 @@ fn format_task_summary(task: &CachingTask) -> String {
378378
let desc = task
379379
.step_description
380380
.as_ref()
381-
.map(|d| format!(": {}", d))
381+
.map(|d| format!(": {d}"))
382382
.unwrap_or_default();
383-
output.push_str(&format!("**Step**: {} of {}{} \n", step, total, desc));
383+
output.push_str(&format!("**Step**: {step} of {total}{desc} \n"));
384384
}
385385
}
386386
output.push_str(&format!(
@@ -435,7 +435,7 @@ fn format_task_summary(task: &CachingTask) -> String {
435435
} else {
436436
error.clone()
437437
};
438-
output.push_str(&format!("**Error**: {}\n\n", error_preview));
438+
output.push_str(&format!("**Error**: {error_preview}\n\n"));
439439
}
440440
output.push_str("**Actions**:\n");
441441
output.push_str(&format!(

rust-docs-mcp/src/cache/tools.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ impl CacheTools {
515515
// Expand path (handles ~ and relative paths)
516516
let expanded_path = match shellexpand::full(path) {
517517
Ok(p) => p,
518-
Err(e) => return Err(format!("Failed to expand path: {}", e)),
518+
Err(e) => return Err(format!("Failed to expand path: {e}")),
519519
};
520520
let local_path = Path::new(expanded_path.as_ref());
521521

@@ -555,8 +555,7 @@ impl CacheTools {
555555
// Validate provided version matches
556556
if provided != actual_version {
557557
return Err(format!(
558-
"Version mismatch: provided '{}' does not match actual '{}' in Cargo.toml",
559-
provided, actual_version
558+
"Version mismatch: provided '{provided}' does not match actual '{actual_version}' in Cargo.toml"
560559
));
561560
}
562561
Ok((actual_version, false))
@@ -565,10 +564,10 @@ impl CacheTools {
565564
Ok((actual_version, true))
566565
}
567566
}
568-
Err(e) => Err(format!("Failed to read version from Cargo.toml: {}", e)),
567+
Err(e) => Err(format!("Failed to read version from Cargo.toml: {e}")),
569568
}
570569
}
571-
Err(e) => Err(format!("Failed to check workspace status: {}", e)),
570+
Err(e) => Err(format!("Failed to check workspace status: {e}")),
572571
}
573572
}
574573

@@ -616,7 +615,7 @@ impl CacheTools {
616615
} else {
617616
"tag"
618617
};
619-
let details = format!("{}, {}: {}", github_url, ref_type, version);
618+
let details = format!("{github_url}, {ref_type}: {version}");
620619
(params.crate_name.clone(), version, Some(details))
621620
}
622621
"local" => {
@@ -632,13 +631,13 @@ impl CacheTools {
632631
match Self::resolve_local_version(&path, params.version.as_deref()) {
633632
Ok(result) => result,
634633
Err(error_msg) => {
635-
return format!("# Error\n\n{}", error_msg);
634+
return format!("# Error\n\n{error_msg}");
636635
}
637636
};
638637

639638
// Add auto-detection note to source details
640639
let details = if auto_detected {
641-
format!("{} (version auto-detected from Cargo.toml)", path)
640+
format!("{path} (version auto-detected from Cargo.toml)")
642641
} else {
643642
path
644643
};
@@ -799,7 +798,7 @@ impl CacheTools {
799798

800799
return match self.task_manager.cancel_task(task_id).await {
801800
Some(task) => task_formatter::format_cancel_result(&task),
802-
None => format!("# Error\n\nTask `{}` not found.", task_id),
801+
None => format!("# Error\n\nTask `{task_id}` not found."),
803802
};
804803
}
805804

@@ -813,10 +812,9 @@ impl CacheTools {
813812
task_formatter::format_clear_result(vec![task])
814813
}
815814
Some(_) => format!(
816-
"# Error\n\nCannot clear task `{}` because it is still in progress. Cancel it first or wait for completion.",
817-
task_id
815+
"# Error\n\nCannot clear task `{task_id}` because it is still in progress. Cancel it first or wait for completion."
818816
),
819-
None => format!("# Error\n\nTask `{}` not found.", task_id),
817+
None => format!("# Error\n\nTask `{task_id}` not found."),
820818
}
821819
} else {
822820
// Clear all terminal tasks
@@ -830,7 +828,7 @@ impl CacheTools {
830828
// Get specific task
831829
match self.task_manager.get_task(task_id).await {
832830
Some(task) => task_formatter::format_single_task(&task),
833-
None => format!("# Error\n\nTask `{}` not found.", task_id),
831+
None => format!("# Error\n\nTask `{task_id}` not found."),
834832
}
835833
} else {
836834
// List all tasks with optional filter

rust-docs-mcp/src/search/indexer.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,11 @@ impl SearchIndexer {
176176
documents.push(doc);
177177

178178
// Report progress every 50 items during document creation (0-70%)
179-
if let Some(ref callback) = progress_callback {
180-
if i % 50 == 0 || i == total_items - 1 {
179+
if let Some(ref callback) = progress_callback
180+
&& (i % 50 == 0 || i == total_items - 1) {
181181
let percent = ((i * 70) / total_items.max(1)).min(70) as u8;
182182
callback(percent);
183183
}
184-
}
185184
}
186185

187186
// Then add all documents to the writer
@@ -190,12 +189,11 @@ impl SearchIndexer {
190189
writer.add_document(doc.clone())?;
191190

192191
// Report progress during writing (70-95%)
193-
if let Some(ref callback) = progress_callback {
194-
if i % 50 == 0 || i == documents.len() - 1 {
192+
if let Some(ref callback) = progress_callback
193+
&& (i % 50 == 0 || i == documents.len() - 1) {
195194
let percent = (70 + ((i * 25) / documents.len().max(1))).min(95) as u8;
196195
callback(percent);
197196
}
198-
}
199197
}
200198

201199
writer.commit()?;

0 commit comments

Comments
 (0)