Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,9 @@ assets = [
["contrib/librespot.service", "lib/systemd/system/", "644"],
["contrib/librespot.user.service", "lib/systemd/user/", "644"],
]

[workspace.lints]
clippy.redundant_closure_for_method_calls = "warn"

[lints]
workspace = true
Comment thread
photovoltex marked this conversation as resolved.
3 changes: 3 additions & 0 deletions audio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ log = "0.4"
tempfile = "3"
thiserror = "2"
tokio = { version = "1", features = ["macros", "sync"] }

[lints]
workspace = true
6 changes: 5 additions & 1 deletion audio/src/fetch/receive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ async fn receive_data(
}

let body = response.into_body();
let data = match body.collect().await.map(|b| b.to_bytes()) {
let data = match body
.collect()
.await
.map(http_body_util::Collected::to_bytes)
{
Ok(bytes) => bytes,
Err(e) => break Err(e.into()),
};
Expand Down
3 changes: 3 additions & 0 deletions connect/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ thiserror = "2"
tokio = { version = "1", features = ["macros", "sync"] }
tokio-stream = { version = "0.1", default-features = false }
uuid = { version = "1.18", default-features = false, features = ["v4"] }

[lints]
workspace = true
2 changes: 1 addition & 1 deletion connect/src/context_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl ContextResolver {
let last_try = self
.unavailable_contexts
.get(&resolve)
.map(|i| i.duration_since(Instant::now()));
.map(Instant::elapsed);

let last_try = if matches!(last_try, Some(last_try) if last_try > RETRY_UNAVAILABLE) {
let _ = self.unavailable_contexts.remove(&resolve);
Expand Down
3 changes: 3 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,6 @@ vergen-gitcl = { version = "1.0", default-features = false, features = [

[dev-dependencies]
tokio = { version = "1", features = ["macros"] }

[lints]
workspace = true
5 changes: 1 addition & 4 deletions core/src/http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,7 @@ impl HttpClient {
let domain = match req.uri().host() {
Some(host) => {
// strip the prefix from *.domain.tld (assume rate limit is per domain, not subdomain)
let mut parts = host
.split('.')
.map(|s| s.to_string())
.collect::<Vec<String>>();
let mut parts = host.split('.').map(Into::into).collect::<Vec<String>>();
let n = parts.len().saturating_sub(2);
parts.drain(n..).collect()
}
Expand Down
6 changes: 3 additions & 3 deletions core/src/spclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ impl SpClient {
let mut headers = headers.unwrap_or_default();
headers.insert(ACCEPT, HeaderValue::from_static("application/json"));

self.request(method, endpoint, Some(headers), body.map(|s| s.as_bytes()))
self.request(method, endpoint, Some(headers), body.map(str::as_bytes))
.await
}

Expand Down Expand Up @@ -749,7 +749,7 @@ impl SpClient {

let previous_track_str = previous_tracks
.iter()
.map(|track| track.to_base62())
.map(SpotifyId::to_base62)
.collect::<Vec<_>>()
.join(",");
// better than checking `previous_tracks.len() > 0` because the `filter_map` could still return 0 items
Expand Down Expand Up @@ -952,7 +952,7 @@ impl SpClient {
&Method::POST,
&endpoint,
None,
body.as_deref().map(|s| s.as_bytes()),
body.as_deref().map(str::as_bytes),
&NO_METRICS_AND_SALT,
)
.await
Expand Down
3 changes: 3 additions & 0 deletions discovery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,6 @@ zbus = { version = "5", default-features = false, features = [
futures = "0.3"
hex = "0.4"
tokio = { version = "1", features = ["macros", "rt"] }

[lints]
workspace = true
3 changes: 3 additions & 0 deletions metadata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "2"
uuid = { version = "1", default-features = false }

[lints]
workspace = true
2 changes: 1 addition & 1 deletion metadata/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct Images(pub Vec<Image>);

impl From<&ImageGroup> for Images {
fn from(image_group: &ImageGroup) -> Self {
Self(image_group.image.iter().map(|i| i.into()).collect())
Self(image_group.image.iter().map(Into::into).collect())
}
}

Expand Down
2 changes: 1 addition & 1 deletion metadata/src/lyrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl TryFrom<&Bytes> for Lyrics {
type Error = Error;

fn try_from(lyrics: &Bytes) -> Result<Self, Self::Error> {
serde_json::from_slice(lyrics).map_err(|err| err.into())
serde_json::from_slice(lyrics).map_err(Into::into)
}
}

Expand Down
4 changes: 2 additions & 2 deletions metadata/src/playlist/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl TryFrom<&PlaylistPartialAttributesMessage> for PlaylistPartialAttributes {
no_value: attributes
.no_value
.iter()
.map(|v| v.enum_value_or_default())
.map(protobuf::EnumOrUnknown::enum_value_or_default)
.collect::<Vec<PlaylistAttributeKind>>()
.as_slice()
.into(),
Expand All @@ -160,7 +160,7 @@ impl TryFrom<&PlaylistPartialItemAttributesMessage> for PlaylistPartialItemAttri
no_value: attributes
.no_value
.iter()
.map(|v| v.enum_value_or_default())
.map(protobuf::EnumOrUnknown::enum_value_or_default)
.collect::<Vec<PlaylistItemAttributeKind>>()
.as_slice()
.into(),
Expand Down
4 changes: 2 additions & 2 deletions metadata/src/playlist/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl TryFrom<&<Playlist as Metadata>::Message> for SelectedListContent {
playlist
.resulting_revisions
.iter()
.map(|p| p.try_into())
.map(std::convert::TryInto::try_into)
.collect::<Result<Vec<SpotifyId>, Error>>()?,
),
has_multiple_heads: playlist.multiple_heads(),
Expand All @@ -183,7 +183,7 @@ impl TryFrom<&<Playlist as Metadata>::Message> for SelectedListContent {
playlist
.geoblock
.iter()
.map(|b| b.enum_value_or_default())
.map(protobuf::EnumOrUnknown::enum_value_or_default)
.collect(),
),
})
Expand Down
2 changes: 1 addition & 1 deletion metadata/src/playlist/permission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl From<&CapabilitiesMessage> for Capabilities {
playlist
.grantable_level
.iter()
.map(|l| l.enum_value_or_default())
.map(protobuf::EnumOrUnknown::enum_value_or_default)
.collect(),
),
can_edit_metadata: playlist.can_edit_metadata(),
Expand Down
7 changes: 2 additions & 5 deletions metadata/src/restriction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ impl_deref_wrapped!(RestrictionCatalogues, Vec<RestrictionCatalogue>);

impl Restriction {
fn parse_country_codes(country_codes: &str) -> Vec<String> {
country_codes
.chunks(2)
.map(|country_code| country_code.to_owned())
.collect()
country_codes.chunks(2).map(Into::into).collect()
}
}

Expand All @@ -58,7 +55,7 @@ impl From<&RestrictionMessage> for Restriction {
catalogues: restriction
.catalogue
.iter()
.map(|c| c.enum_value_or_default())
.map(protobuf::EnumOrUnknown::enum_value_or_default)
.collect::<Vec<RestrictionCatalogue>>()
.as_slice()
.into(),
Expand Down
3 changes: 3 additions & 0 deletions oauth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@ env_logger = { version = "0.11", default-features = false, features = [
"auto-color",
] }
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }

[lints]
workspace = true
2 changes: 1 addition & 1 deletion oauth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ pub fn get_access_token(

let token_scopes: Vec<String> = match token.scopes() {
Some(s) => s.iter().map(|s| s.to_string()).collect(),
_ => scopes.into_iter().map(|s| s.to_string()).collect(),
_ => scopes.into_iter().map(Into::into).collect(),
};
let refresh_token = match token.refresh_token() {
Some(t) => t.secret().to_string(),
Expand Down
3 changes: 3 additions & 0 deletions playback/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,6 @@ rand_distr = "0.5"

# Local file handling
form_urlencoded = "1.2.2"

[lints]
workspace = true
2 changes: 1 addition & 1 deletion playback/src/local_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct LocalFileLookup(HashMap<SpotifyUri, PathBuf>);

impl LocalFileLookup {
pub fn get(&self, uri: &SpotifyUri) -> Option<&Path> {
self.0.get(uri).map(|p| p.as_path())
self.0.get(uri).map(PathBuf::as_path)
}
}

Expand Down
3 changes: 3 additions & 0 deletions protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ protobuf = "3"

[build-dependencies]
protobuf-codegen = "3"

[lints]
workspace = true
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ async fn get_setup() -> Setup {
let cache = {
let volume_dir = opt_str(SYSTEM_CACHE)
.or_else(|| opt_str(CACHE))
.map(|p| p.into());
.map(Into::into);

let cred_dir = if opt_present(DISABLE_CREDENTIAL_CACHE) {
None
Expand Down