From 0166cea60c10842145c5d4ec5da617807bf9f11a Mon Sep 17 00:00:00 2001 From: Wojciech Kozlowski Date: Sat, 6 Jan 2024 11:11:43 +0100 Subject: [PATCH] Fix expanded clippy lints --- src/database/json/mod.rs | 2 +- src/lib.rs | 44 +++++++-------- src/tui/mod.rs | 2 +- src/tui/ui.rs | 12 ++--- tests/library/beets.rs | 4 +- tests/testlib.rs | 114 +++++++++++++++++++-------------------- 6 files changed, 89 insertions(+), 89 deletions(-) diff --git a/src/database/json/mod.rs b/src/database/json/mod.rs index af200ca..6013fbb 100644 --- a/src/database/json/mod.rs +++ b/src/database/json/mod.rs @@ -76,7 +76,7 @@ mod tests { } } - fn vec_to_urls(vec: &Vec) -> String { + fn vec_to_urls(vec: &[U]) -> String { let mut urls: Vec = vec![]; for item in vec.iter() { urls.push(format!("\"{}\"", item.url())); diff --git a/src/lib.rs b/src/lib.rs index f32b21e..2adafd6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -651,19 +651,19 @@ mod tests { assert_eq!(url, mb.url()); assert_eq!(uuid, mb.mbid()); - let url = format!("not a url at all"); + let url = "not a url at all".to_string(); let expected_error: Error = url::ParseError::RelativeUrlWithoutBase.into(); - let actual_error = MusicBrainz::new(&url).unwrap_err(); + let actual_error = MusicBrainz::new(url).unwrap_err(); assert_eq!(actual_error, expected_error); assert_eq!(actual_error.to_string(), expected_error.to_string()); - let url = format!("https://musicbrainz.org/artist/i-am-not-a-uuid"); + let url = "https://musicbrainz.org/artist/i-am-not-a-uuid".to_string(); let expected_error: Error = Uuid::try_parse("i-am-not-a-uuid").unwrap_err().into(); - let actual_error = MusicBrainz::new(&url).unwrap_err(); + let actual_error = MusicBrainz::new(url).unwrap_err(); assert_eq!(actual_error, expected_error); assert_eq!(actual_error.to_string(), expected_error.to_string()); - let url = format!("https://musicbrainz.org/artist"); + let url = "https://musicbrainz.org/artist".to_string(); let expected_error: Error = InvalidUrlError { url_type: UrlType::MusicBrainz, url: url.clone(), @@ -681,32 +681,32 @@ mod tests { let bandcamp = "https://thelasthangmen.bandcamp.com/"; let qobuz = "https://www.qobuz.com/nl-nl/interpreter/the-last-hangmen/1244413"; - assert!(MusicBrainz::new(&musicbrainz).is_ok()); - assert!(MusicBrainz::new(&musicbutler).is_err()); - assert!(MusicBrainz::new(&bandcamp).is_err()); - assert!(MusicBrainz::new(&qobuz).is_err()); + assert!(MusicBrainz::new(musicbrainz).is_ok()); + assert!(MusicBrainz::new(musicbutler).is_err()); + assert!(MusicBrainz::new(bandcamp).is_err()); + assert!(MusicBrainz::new(qobuz).is_err()); - assert!(MusicButler::new(&musicbrainz).is_err()); - assert!(MusicButler::new(&musicbutler).is_ok()); - assert!(MusicButler::new(&bandcamp).is_err()); - assert!(MusicButler::new(&qobuz).is_err()); + assert!(MusicButler::new(musicbrainz).is_err()); + assert!(MusicButler::new(musicbutler).is_ok()); + assert!(MusicButler::new(bandcamp).is_err()); + assert!(MusicButler::new(qobuz).is_err()); - assert!(Bandcamp::new(&musicbrainz).is_err()); - assert!(Bandcamp::new(&musicbutler).is_err()); - assert!(Bandcamp::new(&bandcamp).is_ok()); - assert!(Bandcamp::new(&qobuz).is_err()); + assert!(Bandcamp::new(musicbrainz).is_err()); + assert!(Bandcamp::new(musicbutler).is_err()); + assert!(Bandcamp::new(bandcamp).is_ok()); + assert!(Bandcamp::new(qobuz).is_err()); - assert!(Qobuz::new(&musicbrainz).is_err()); - assert!(Qobuz::new(&musicbutler).is_err()); - assert!(Qobuz::new(&bandcamp).is_err()); - assert!(Qobuz::new(&qobuz).is_ok()); + assert!(Qobuz::new(musicbrainz).is_err()); + assert!(Qobuz::new(musicbutler).is_err()); + assert!(Qobuz::new(bandcamp).is_err()); + assert!(Qobuz::new(qobuz).is_ok()); } #[test] fn merge_track() { let left = Track { id: TrackId { - number: 04, + number: 4, title: String::from("a title"), }, artist: vec![String::from("left artist")], diff --git a/src/tui/mod.rs b/src/tui/mod.rs index 400bf18..03f4be8 100644 --- a/src/tui/mod.rs +++ b/src/tui/mod.rs @@ -199,7 +199,7 @@ mod tests { listener.expect_spawn().return_once(|| { thread::spawn(|| { thread::park(); - return EventError::Io(io::Error::new(io::ErrorKind::Interrupted, "unparked")); + EventError::Io(io::Error::new(io::ErrorKind::Interrupted, "unparked")) }) }); listener diff --git a/src/tui/ui.rs b/src/tui/ui.rs index d1ed16a..8ca4b23 100644 --- a/src/tui/ui.rs +++ b/src/tui/ui.rs @@ -760,7 +760,7 @@ mod tests { let empty = TrackSelection::initialise(None); assert_eq!(empty.state.selected(), None); - let empty = TrackSelection::initialise(Some(&vec![])); + let empty = TrackSelection::initialise(Some(&[])); assert_eq!(empty.state.selected(), None); let mut sel = TrackSelection::initialise(Some(tracks)); @@ -784,7 +784,7 @@ mod tests { sel.state.select(Some(std::usize::MAX)); assert_eq!(sel.state.selected(), Some(std::usize::MAX)); - sel.increment(&vec![]); + sel.increment(&[]); assert_eq!(sel.state.selected(), Some(std::usize::MAX)); } @@ -796,7 +796,7 @@ mod tests { let empty = AlbumSelection::initialise(None); assert_eq!(empty.state.selected(), None); - let empty = AlbumSelection::initialise(Some(&vec![])); + let empty = AlbumSelection::initialise(Some(&[])); assert_eq!(empty.state.selected(), None); let mut sel = AlbumSelection::initialise(Some(albums)); @@ -841,7 +841,7 @@ mod tests { assert_eq!(sel.state.selected(), Some(std::usize::MAX)); assert_eq!(sel.track.state.selected(), Some(1)); - sel.increment(&vec![]); + sel.increment(&[]); assert_eq!(sel.state.selected(), Some(std::usize::MAX)); assert_eq!(sel.track.state.selected(), Some(1)); } @@ -854,7 +854,7 @@ mod tests { let empty = ArtistSelection::initialise(None); assert_eq!(empty.state.selected(), None); - let empty = ArtistSelection::initialise(Some(&vec![])); + let empty = ArtistSelection::initialise(Some(&[])); assert_eq!(empty.state.selected(), None); let mut sel = ArtistSelection::initialise(Some(artists)); @@ -899,7 +899,7 @@ mod tests { assert_eq!(sel.state.selected(), Some(std::usize::MAX)); assert_eq!(sel.album.state.selected(), Some(1)); - sel.increment(&vec![]); + sel.increment(&[]); assert_eq!(sel.state.selected(), Some(std::usize::MAX)); assert_eq!(sel.album.state.selected(), Some(1)); } diff --git a/tests/library/beets.rs b/tests/library/beets.rs index 451cc49..96d1889 100644 --- a/tests/library/beets.rs +++ b/tests/library/beets.rs @@ -117,7 +117,7 @@ fn test_album_title_query() { let beets = &mut beets_arc.lock().unwrap(); let output = beets - .list(&Query::new().include(Field::AlbumTitle(String::from("Slovo")))) + .list(Query::new().include(Field::AlbumTitle(String::from("Slovo")))) .unwrap(); let expected: Vec = artists_to_items(&COLLECTION[4..5]); @@ -130,7 +130,7 @@ fn test_exclude_query() { let beets = &mut beets_arc.lock().unwrap(); let output = beets - .list(&Query::new().exclude(Field::AlbumArtist(String::from("Аркона")))) + .list(Query::new().exclude(Field::AlbumArtist(String::from("Аркона")))) .unwrap(); let expected: Vec = artists_to_items(&COLLECTION[..4]); diff --git a/tests/testlib.rs b/tests/testlib.rs index 10745b3..007e76b 100644 --- a/tests/testlib.rs +++ b/tests/testlib.rs @@ -31,7 +31,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { tracks: vec![ Track { id: TrackId { - number: 01, + number: 1, title: String::from("Verja Urit an Bitus"), }, artist: vec![String::from("Eluveitie")], @@ -42,7 +42,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 02, + number: 2, title: String::from("Uis Elveti"), }, artist: vec![String::from("Eluveitie")], @@ -53,7 +53,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 03, + number: 3, title: String::from("Ôrô"), }, artist: vec![String::from("Eluveitie")], @@ -64,7 +64,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 04, + number: 4, title: String::from("Lament"), }, artist: vec![String::from("Eluveitie")], @@ -75,7 +75,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 05, + number: 5, title: String::from("Druid"), }, artist: vec![String::from("Eluveitie")], @@ -86,7 +86,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 06, + number: 6, title: String::from("Jêzaïg"), }, artist: vec![String::from("Eluveitie")], @@ -105,7 +105,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { tracks: vec![ Track { id: TrackId { - number: 01, + number: 1, title: String::from("Samon"), }, artist: vec![String::from("Eluveitie")], @@ -116,7 +116,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 02, + number: 2, title: String::from("Primordial Breath"), }, artist: vec![String::from("Eluveitie")], @@ -127,7 +127,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 03, + number: 3, title: String::from("Inis Mona"), }, artist: vec![String::from("Eluveitie")], @@ -138,7 +138,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 04, + number: 4, title: String::from("Gray Sublime Archon"), }, artist: vec![String::from("Eluveitie")], @@ -149,7 +149,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 05, + number: 5, title: String::from("Anagantios"), }, artist: vec![String::from("Eluveitie")], @@ -160,7 +160,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 06, + number: 6, title: String::from("Bloodstained Ground"), }, artist: vec![String::from("Eluveitie")], @@ -171,7 +171,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 07, + number: 7, title: String::from("The Somber Lay"), }, artist: vec![String::from("Eluveitie")], @@ -182,7 +182,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 08, + number: 8, title: String::from("Slanias Song"), }, artist: vec![String::from("Eluveitie")], @@ -193,7 +193,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 09, + number: 9, title: String::from("Giamonios"), }, artist: vec![String::from("Eluveitie")], @@ -263,7 +263,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { tracks: vec![ Track { id: TrackId { - number: 01, + number: 1, title: String::from("Intro = Chaos"), }, artist: vec![String::from("Frontside")], @@ -274,7 +274,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 02, + number: 2, title: String::from("Modlitwa"), }, artist: vec![String::from("Frontside")], @@ -285,7 +285,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 03, + number: 3, title: String::from("Długa droga z piekła"), }, artist: vec![String::from("Frontside")], @@ -296,7 +296,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 04, + number: 4, title: String::from("Synowie ognia"), }, artist: vec![String::from("Frontside")], @@ -307,7 +307,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 05, + number: 5, title: String::from("1902"), }, artist: vec![String::from("Frontside")], @@ -318,7 +318,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 06, + number: 6, title: String::from("Krew za krew"), }, artist: vec![String::from("Frontside")], @@ -329,7 +329,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 07, + number: 7, title: String::from("Kulminacja"), }, artist: vec![String::from("Frontside")], @@ -340,7 +340,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 08, + number: 8, title: String::from("Judasz"), }, artist: vec![String::from("Frontside")], @@ -351,7 +351,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 09, + number: 9, title: String::from("Więzy"), }, artist: vec![String::from("Frontside")], @@ -409,7 +409,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { tracks: vec![ Track { id: TrackId { - number: 01, + number: 1, title: String::from("Unbreakable"), }, artist: vec![String::from("Heaven’s Basement")], @@ -420,7 +420,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 02, + number: 2, title: String::from("Guilt Trips and Sins"), }, artist: vec![String::from("Heaven’s Basement")], @@ -431,7 +431,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 03, + number: 3, title: String::from("The Long Goodbye"), }, artist: vec![String::from("Heaven’s Basement")], @@ -442,7 +442,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 04, + number: 4, title: String::from("Close Encounters"), }, artist: vec![String::from("Heaven’s Basement")], @@ -453,7 +453,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 05, + number: 5, title: String::from("Paranoia"), }, artist: vec![String::from("Heaven’s Basement")], @@ -464,7 +464,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 06, + number: 6, title: String::from("Let Me Out of Here"), }, artist: vec![String::from("Heaven’s Basement")], @@ -475,7 +475,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 07, + number: 7, title: String::from("Leeches"), }, artist: vec![String::from("Heaven’s Basement")], @@ -512,7 +512,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { tracks: vec![ Track { id: TrackId { - number: 01, + number: 1, title: String::from("Fight Fire with Fire"), }, artist: vec![String::from("Metallica")], @@ -523,7 +523,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 02, + number: 2, title: String::from("Ride the Lightning"), }, artist: vec![String::from("Metallica")], @@ -534,7 +534,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 03, + number: 3, title: String::from("For Whom the Bell Tolls"), }, artist: vec![String::from("Metallica")], @@ -545,7 +545,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 04, + number: 4, title: String::from("Fade to Black"), }, artist: vec![String::from("Metallica")], @@ -556,7 +556,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 05, + number: 5, title: String::from("Trapped under Ice"), }, artist: vec![String::from("Metallica")], @@ -567,7 +567,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 06, + number: 6, title: String::from("Escape"), }, artist: vec![String::from("Metallica")], @@ -578,7 +578,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 07, + number: 7, title: String::from("Creeping Death"), }, artist: vec![String::from("Metallica")], @@ -589,7 +589,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 08, + number: 8, title: String::from("The Call of Ktulu"), }, artist: vec![String::from("Metallica")], @@ -608,7 +608,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { tracks: vec![ Track { id: TrackId { - number: 01, + number: 1, title: String::from("The Ecstasy of Gold"), }, artist: vec![String::from("Metallica")], @@ -619,7 +619,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 02, + number: 2, title: String::from("The Call of Ktulu"), }, artist: vec![String::from("Metallica")], @@ -630,7 +630,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 03, + number: 3, title: String::from("Master of Puppets"), }, artist: vec![String::from("Metallica")], @@ -641,7 +641,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 04, + number: 4, title: String::from("Of Wolf and Man"), }, artist: vec![String::from("Metallica")], @@ -652,7 +652,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 05, + number: 5, title: String::from("The Thing That Should Not Be"), }, artist: vec![String::from("Metallica")], @@ -663,7 +663,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 06, + number: 6, title: String::from("Fuel"), }, artist: vec![String::from("Metallica")], @@ -674,7 +674,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 07, + number: 7, title: String::from("The Memory Remains"), }, artist: vec![String::from("Metallica")], @@ -685,7 +685,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 08, + number: 8, title: String::from("No Leaf Clover"), }, artist: vec![String::from("Metallica")], @@ -696,7 +696,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 09, + number: 9, title: String::from("Hero of the Day"), }, artist: vec![String::from("Metallica")], @@ -867,7 +867,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { tracks: vec![ Track { id: TrackId { - number: 01, + number: 1, title: String::from("Az’"), }, artist: vec![String::from("Аркона")], @@ -878,7 +878,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 02, + number: 2, title: String::from("Arkaim"), }, artist: vec![String::from("Аркона")], @@ -889,7 +889,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 03, + number: 3, title: String::from("Bol’no mne"), }, artist: vec![String::from("Аркона")], @@ -900,7 +900,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 04, + number: 4, title: String::from("Leshiy"), }, artist: vec![String::from("Аркона")], @@ -911,7 +911,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 05, + number: 5, title: String::from("Zakliatie"), }, artist: vec![String::from("Аркона")], @@ -922,7 +922,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 06, + number: 6, title: String::from("Predok"), }, artist: vec![String::from("Аркона")], @@ -933,7 +933,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 07, + number: 7, title: String::from("Nikogda"), }, artist: vec![String::from("Аркона")], @@ -944,7 +944,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 08, + number: 8, title: String::from("Tam za tumanami"), }, artist: vec![String::from("Аркона")], @@ -955,7 +955,7 @@ pub static COLLECTION: Lazy> = Lazy::new(|| -> Collection { }, Track { id: TrackId { - number: 09, + number: 9, title: String::from("Potomok"), }, artist: vec![String::from("Аркона")],