From 4a59611311f67c460dc86e6f106592c5cf38b459 Mon Sep 17 00:00:00 2001 From: Wojciech Kozlowski Date: Sat, 11 Jan 2025 16:02:47 +0100 Subject: [PATCH] Clippy lints --- Cargo.toml | 2 +- src/external/database/sql/backend.rs | 14 +++++++------- src/external/database/sql/mod.rs | 5 ++++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5d159f8..a47e9c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,7 @@ tempfile = "3.15.0" [features] default = ["database-json", "library-beets"] bin = ["structopt"] -database-sqlite = ["rusqlite"] +database-sqlite = ["rusqlite", "serde", "serde_json"] database-json = ["serde", "serde_json"] library-beets = [] library-beets-ssh = ["openssh", "tokio"] diff --git a/src/external/database/sql/backend.rs b/src/external/database/sql/backend.rs index 06fc99d..41efd1c 100644 --- a/src/external/database/sql/backend.rs +++ b/src/external/database/sql/backend.rs @@ -36,7 +36,7 @@ impl SqlDatabaseSqliteBackend { } } -impl<'conn> SqlTransactionSqliteBackend<'conn> { +impl SqlTransactionSqliteBackend<'_> { fn prepare(&self, sql: &str) -> Result { self.tx .prepare(sql) @@ -88,7 +88,7 @@ impl<'conn> ISqlDatabaseBackend<'conn> for SqlDatabaseSqliteBackend { } } -impl<'conn> ISqlTransactionBackend for SqlTransactionSqliteBackend<'conn> { +impl ISqlTransactionBackend for SqlTransactionSqliteBackend<'_> { fn commit(self) -> Result<(), Error> { self.tx .commit() @@ -151,7 +151,7 @@ impl<'conn> ISqlTransactionBackend for SqlTransactionSqliteBackend<'conn> { Self::execute(&mut stmt, ()) } - fn insert_database_version<'a>(&self, version: &SerializeDatabase<'a>) -> Result<(), Error> { + fn insert_database_version(&self, version: &SerializeDatabase<'_>) -> Result<(), Error> { let mut stmt = self.prepare_cached( "INSERT INTO database_metadata (name, value) VALUES (?1, ?2)", @@ -169,10 +169,10 @@ impl<'conn> ISqlTransactionBackend for SqlTransactionSqliteBackend<'conn> { match Self::next_row(&mut rows)? { Some(row) => { - let version: String = Self::get_value(&row, 0)?; + let version: String = Self::get_value(row, 0)?; match version.as_str() { "V20250103" => Ok(DeserializeDatabase::V20250103(vec![])), - s @ _ => Err(Error::SerDeError(format!("unknown database version: {s}"))), + s => Err(Error::SerDeError(format!("unknown database version: {s}"))), } } None => Err(Error::SerDeError(String::from( @@ -181,7 +181,7 @@ impl<'conn> ISqlTransactionBackend for SqlTransactionSqliteBackend<'conn> { } } - fn insert_artist<'a>(&self, artist: &SerializeArtist<'a>) -> Result<(), Error> { + fn insert_artist(&self, artist: &SerializeArtist<'_>) -> Result<(), Error> { let mut stmt = self.prepare_cached( "INSERT INTO artists (name, sort, mbid, properties) VALUES (?1, ?2, ?3, ?4)", @@ -215,7 +215,7 @@ impl<'conn> ISqlTransactionBackend for SqlTransactionSqliteBackend<'conn> { Ok(artists) } - fn insert_album<'a>(&self, artist_name: &str, album: &SerializeAlbum<'a>) -> Result<(), Error> { + fn insert_album(&self, artist_name: &str, album: &SerializeAlbum<'_>) -> Result<(), Error> { let mut stmt = self.prepare_cached( "INSERT INTO albums (title, lib_id, mbid, artist_name, year, month, day, seq, primary_type, secondary_types) diff --git a/src/external/database/sql/mod.rs b/src/external/database/sql/mod.rs index 137ecee..93b4bb7 100644 --- a/src/external/database/sql/mod.rs +++ b/src/external/database/sql/mod.rs @@ -51,18 +51,21 @@ pub trait ISqlTransactionBackend { fn drop_albums_table(&self) -> Result<(), Error>; /// Set the database version. + #[allow(clippy::needless_lifetimes)] // Conflicts with automock. fn insert_database_version<'a>(&self, version: &SerializeDatabase<'a>) -> Result<(), Error>; /// Get the database version. - fn select_database_version<'a>(&self) -> Result; + fn select_database_version(&self) -> Result; /// Insert an artist into the artist table. + #[allow(clippy::needless_lifetimes)] // Conflicts with automock. fn insert_artist<'a>(&self, artist: &SerializeArtist<'a>) -> Result<(), Error>; /// Get all artists from the artist table. fn select_all_artists(&self) -> Result, Error>; /// Insert an artist into the artist table. + #[allow(clippy::needless_lifetimes)] // Conflicts with automock. fn insert_album<'a>(&self, artist_name: &str, album: &SerializeAlbum<'a>) -> Result<(), Error>; /// Get all albums from the album table.