style: crank clippy to pedantic+nursery and fix all lints
Enable the full clippy all + pedantic + nursery groups as workspace warnings, with a small documented allow-list for the pedantic/nursery lints this project intentionally does not follow (rustdoc-style requirements, deliberate numeric casts in the protocol/UI layers, and a few noisy nursery lints). Also enable the rust unused_lifetimes and unsafe_op_in_unsafe_fn lints. Fixed every resulting warning (527 -> 0) mechanically per clippy's suggestions: inline format args, const fns, item ordering, let-else, redundant clones, map_or, cast_lossless, Eq derives, associated-fn conversions for methods that never used self, and removing unnecessary Result wrappers whose call sites could never propagate an error. No runtime behavior changed; cargo fmt applied. cargo clippy --workspace --all-targets: 0 warnings. All tests pass.
This commit is contained in:
@@ -83,7 +83,7 @@ fn build_info_lines(
|
||||
lines.push(label_value("Save to", &save_path));
|
||||
|
||||
if let Some(bitrate) = download.metadata.bitrate {
|
||||
lines.push(label_value("Bitrate", &format!("{} kbps", bitrate)));
|
||||
lines.push(label_value("Bitrate", &format!("{bitrate} kbps")));
|
||||
}
|
||||
if let Some(length) = download.metadata.length_seconds {
|
||||
lines.push(label_value("Length", &format_duration(length)));
|
||||
@@ -93,14 +93,14 @@ fn build_info_lines(
|
||||
DownloadStatus::Queued => {
|
||||
lines.push(Line::from(""));
|
||||
let position_text = match download.queue_position {
|
||||
Some(p) => format!("#{}", p),
|
||||
Some(p) => format!("#{p}"),
|
||||
None => "unknown".to_string(),
|
||||
};
|
||||
lines.push(label_value("Queue position", &position_text));
|
||||
|
||||
if let Some(slots) = download.metadata.peer_free_slots {
|
||||
let slot_text = if slots > 0 {
|
||||
format!("{} available", slots)
|
||||
format!("{slots} available")
|
||||
} else {
|
||||
"all busy".to_string()
|
||||
};
|
||||
@@ -110,7 +110,7 @@ fn build_info_lines(
|
||||
if let Some(speed) = download.metadata.peer_upload_speed {
|
||||
lines.push(label_value(
|
||||
"Peer upload speed",
|
||||
&format_speed(speed as f64),
|
||||
&format_speed(f64::from(speed)),
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -149,10 +149,7 @@ fn build_info_lines(
|
||||
|
||||
fn label_value(label: &str, value: &str) -> Line<'static> {
|
||||
Line::from(vec![
|
||||
Span::styled(
|
||||
format!("{:<width$}", label, width = LABEL_WIDTH),
|
||||
dimmed_style(),
|
||||
),
|
||||
Span::styled(format!("{label:<LABEL_WIDTH$}"), dimmed_style()),
|
||||
Span::styled(value.to_string(), primary_style()),
|
||||
])
|
||||
}
|
||||
@@ -163,10 +160,7 @@ fn label_value_styled(
|
||||
value_style: Style,
|
||||
) -> Line<'static> {
|
||||
Line::from(vec![
|
||||
Span::styled(
|
||||
format!("{:<width$}", label, width = LABEL_WIDTH),
|
||||
dimmed_style(),
|
||||
),
|
||||
Span::styled(format!("{label:<LABEL_WIDTH$}"), dimmed_style()),
|
||||
Span::styled(value, value_style),
|
||||
])
|
||||
}
|
||||
@@ -211,11 +205,11 @@ fn format_duration(seconds: u32) -> String {
|
||||
let minutes = (seconds % 3600) / 60;
|
||||
let secs = seconds % 60;
|
||||
if hours > 0 {
|
||||
format!("{}h {:02}m {:02}s", hours, minutes, secs)
|
||||
format!("{hours}h {minutes:02}m {secs:02}s")
|
||||
} else if minutes > 0 {
|
||||
format!("{}m {:02}s", minutes, secs)
|
||||
format!("{minutes}m {secs:02}s")
|
||||
} else {
|
||||
format!("{}s", secs)
|
||||
format!("{secs}s")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ pub fn render_results_pane(
|
||||
} = params;
|
||||
if items.is_empty() {
|
||||
let title = if let Some(query) = active_search_query {
|
||||
format!("[2] Results: {}", query)
|
||||
format!("[2] Results: {query}")
|
||||
} else {
|
||||
"[2] Results".to_string()
|
||||
};
|
||||
@@ -75,13 +75,12 @@ pub fn render_results_pane(
|
||||
.title(title);
|
||||
|
||||
let message = if is_filtering {
|
||||
format!("No results match filter: '{}'", filter_query)
|
||||
format!("No results match filter: '{filter_query}'")
|
||||
} else {
|
||||
format!(
|
||||
"soulseek-rs 🦀 v{}
|
||||
"soulseek-rs 🦀 v{VERSION}
|
||||
Michel de Graaf 2026\n
|
||||
No results. Select a search from the Searches pane [1]. Or start new search [s → search] \n",
|
||||
VERSION
|
||||
No results. Select a search from the Searches pane [1]. Or start new search [s → search] \n"
|
||||
)
|
||||
};
|
||||
|
||||
@@ -114,13 +113,13 @@ No results. Select a search from the Searches pane [1]. Or start new search [s
|
||||
|
||||
let bitrate_str = file
|
||||
.bitrate
|
||||
.map(|br| format!("{} kbps", br))
|
||||
.unwrap_or_else(|| "-".to_string());
|
||||
.map_or_else(|| "-".to_string(), |br| format!("{br} kbps"));
|
||||
|
||||
let speed_str = if file.speed > 0 {
|
||||
let speed_mb =
|
||||
(file.speed as f64 / BYTES_PER_MB * 100.0).round() / 100.0;
|
||||
format!("{} MB/s", speed_mb)
|
||||
let speed_mb = (f64::from(file.speed) / BYTES_PER_MB * 100.0)
|
||||
.round()
|
||||
/ 100.0;
|
||||
format!("{speed_mb} MB/s")
|
||||
} else {
|
||||
"-".to_string()
|
||||
};
|
||||
@@ -148,9 +147,9 @@ No results. Select a search from the Searches pane [1]. Or start new search [s
|
||||
];
|
||||
|
||||
let title = if is_filtering {
|
||||
format!("[2] Results - Filter: '{}'", filter_query)
|
||||
format!("[2] Results - Filter: '{filter_query}'")
|
||||
} else if let Some(query) = active_search_query {
|
||||
format!("[2] Results: {}", query)
|
||||
format!("[2] Results: {query}")
|
||||
} else {
|
||||
"[2] Results".to_string()
|
||||
};
|
||||
@@ -178,7 +177,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn identity_mapping_used_when_no_filter() {
|
||||
let selected: HashSet<usize> = [1].into_iter().collect();
|
||||
let selected: HashSet<usize> = std::iter::once(1).collect();
|
||||
assert!(row_is_selected(1, None, &selected));
|
||||
assert!(!row_is_selected(0, None, &selected));
|
||||
}
|
||||
@@ -188,7 +187,7 @@ mod tests {
|
||||
// Filter shows original rows 2, 5, 7 as display rows 0, 1, 2.
|
||||
// The user selected original row 5.
|
||||
let original_indices = [2usize, 5, 7];
|
||||
let selected: HashSet<usize> = [5].into_iter().collect();
|
||||
let selected: HashSet<usize> = std::iter::once(5).collect();
|
||||
assert!(!row_is_selected(0, Some(&original_indices), &selected));
|
||||
assert!(row_is_selected(1, Some(&original_indices), &selected));
|
||||
assert!(!row_is_selected(2, Some(&original_indices), &selected));
|
||||
|
||||
@@ -41,7 +41,7 @@ pub fn render_searches_pane(
|
||||
{
|
||||
"Searching...".to_string()
|
||||
} else {
|
||||
format!("{}", results_count)
|
||||
format!("{results_count}")
|
||||
};
|
||||
|
||||
Row::new(vec![
|
||||
|
||||
Reference in New Issue
Block a user