Skip to content

Commit 2bea4fe

Browse files
fix(clippy): resolve all linter warnings in Rust code
- Replace redundant closures with direct function references (3 fixes in lastfm.rs) - Collapse nested if-let statements using && operator (lastfm.rs, scanner/commands.rs) - Replace manual clamp pattern with .clamp() method (lib.rs) All 8 clippy warnings resolved. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent d5ba0d1 commit 2bea4fe

3 files changed

Lines changed: 25 additions & 27 deletions

File tree

‎crates/mt-tauri/src/commands/lastfm.rs‎

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ pub async fn lastfm_cache_loved_tracks(
771771
// For incremental updates, get the most recent loved_at timestamp
772772
let incremental = incremental.unwrap_or(false);
773773
let since_timestamp = if incremental {
774-
db.with_conn(|conn| lastfm_loved::get_most_recent_loved_at(conn))
774+
db.with_conn(lastfm_loved::get_most_recent_loved_at)
775775
.map_err(|e| format!("Database error: {}", e))?
776776
} else {
777777
None
@@ -795,16 +795,14 @@ pub async fn lastfm_cache_loved_tracks(
795795

796796
// For incremental updates, check if we've reached tracks older than our last fetch
797797
for track in tracks {
798-
if let Some(since_ts) = since_timestamp {
799-
if let Some(date) = &track.date {
800-
if let Some(ts) = date.timestamp() {
801-
if ts <= since_ts {
802-
// We've reached tracks we already have
803-
stop_fetching = true;
804-
break;
805-
}
806-
}
807-
}
798+
if let Some(since_ts) = since_timestamp
799+
&& let Some(date) = &track.date
800+
&& let Some(ts) = date.timestamp()
801+
&& ts <= since_ts
802+
{
803+
// We've reached tracks we already have
804+
stop_fetching = true;
805+
break;
808806
}
809807
all_loved_tracks.push(track);
810808
}
@@ -1007,11 +1005,11 @@ pub async fn lastfm_match_loved_tracks(
10071005
#[tauri::command]
10081006
pub fn lastfm_loved_stats(db: State<Database>) -> Result<LovedTracksStatsResponse, String> {
10091007
let stats = db
1010-
.with_conn(|conn| lastfm_loved::get_loved_stats(conn))
1008+
.with_conn(lastfm_loved::get_loved_stats)
10111009
.map_err(|e| format!("Failed to get loved stats: {}", e))?;
10121010

10131011
let most_recent_loved = db
1014-
.with_conn(|conn| lastfm_loved::get_most_recent_loved_at(conn))
1012+
.with_conn(lastfm_loved::get_most_recent_loved_at)
10151013
.map_err(|e| format!("Failed to get most recent loved: {}", e))?;
10161014

10171015
Ok(LovedTracksStatsResponse {

‎crates/mt-tauri/src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ pub fn run() {
162162
let available_cpus = std::thread::available_parallelism()
163163
.map(|n| n.get())
164164
.unwrap_or(4);
165-
let num_threads = available_cpus.min(4).max(2);
165+
let num_threads = available_cpus.clamp(2, 4);
166166
rayon::ThreadPoolBuilder::new()
167167
.num_threads(num_threads)
168168
.stack_size(2 * 1024 * 1024)

‎crates/mt-tauri/src/scanner/commands.rs‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -173,20 +173,20 @@ pub async fn scan_paths_to_library(
173173

174174
// Auto-favorite tracks that match cached Last.fm loved tracks
175175
let new_filepaths: Vec<String> = truly_new.iter().map(|(fp, _)| fp.clone()).collect();
176-
if let Ok(new_track_ids) = library::get_track_ids_by_filepaths(&conn, &new_filepaths) {
177-
if !new_track_ids.is_empty() {
178-
match match_new_tracks_against_loved(&conn, &new_track_ids) {
179-
Ok(favorited) if favorited > 0 => {
180-
println!(
181-
"[scanner] Auto-favorited {} tracks from Last.fm loved cache",
182-
favorited
183-
);
184-
}
185-
Err(e) => {
186-
eprintln!("[scanner] Failed to auto-favorite from loved cache: {}", e);
187-
}
188-
_ => {}
176+
if let Ok(new_track_ids) = library::get_track_ids_by_filepaths(&conn, &new_filepaths)
177+
&& !new_track_ids.is_empty()
178+
{
179+
match match_new_tracks_against_loved(&conn, &new_track_ids) {
180+
Ok(favorited) if favorited > 0 => {
181+
println!(
182+
"[scanner] Auto-favorited {} tracks from Last.fm loved cache",
183+
favorited
184+
);
185+
}
186+
Err(e) => {
187+
eprintln!("[scanner] Failed to auto-favorite from loved cache: {}", e);
189188
}
189+
_ => {}
190190
}
191191
}
192192
}

0 commit comments

Comments
 (0)