chore: Clippy fixes

This commit is contained in:
Ginger committed 2026-11-20 10:48:04 -05:00
1 parent 6f6e8c4eb5
commit a4ef1ecfa2
24 files changed
+32 -82

No files matched your search

+1
View File
@@ -2,6 +2,7 @@
#![allow(clippy::wildcard_imports)] #![allow(clippy::wildcard_imports)]
#![allow(clippy::enum_glob_use)] #![allow(clippy::enum_glob_use)]
#![allow(clippy::too_many_arguments)] #![allow(clippy::too_many_arguments)]
#![allow(clippy::large_unopt_stack_frames, reason = "very large Subcommand macro expansions")]
conduwuit_macros::introspect_crate! {} conduwuit_macros::introspect_crate! {}
+1 -2
View File
@@ -15,8 +15,7 @@ use ruma::{
OneTimeKeyAlgorithm, OwnedDeviceId, OwnedUserId, UserId, OneTimeKeyAlgorithm, OwnedDeviceId, OwnedUserId, UserId,
api::{ api::{
client::keys::{ client::keys::{
claim_keys, get_key_changes, get_keys, upload_keys, claim_keys, get_key_changes, get_keys, upload_keys, upload_signatures,
upload_signatures::{self},
upload_signing_keys, upload_signing_keys,
}, },
federation, federation,
+1 -4
View File
@@ -16,10 +16,7 @@ use futures::{FutureExt, StreamExt};
use ruma::{ use ruma::{
CanonicalJsonObject, CanonicalJsonValue, OwnedEventId, OwnedRoomId, OwnedServerName, CanonicalJsonObject, CanonicalJsonValue, OwnedEventId, OwnedRoomId, OwnedServerName,
OwnedUserId, RoomId, UserId, OwnedUserId, RoomId, UserId,
api::{ api::{client::knock::knock_room, federation},
client::knock::knock_room,
federation::{self},
},
canonical_json::to_canonical_value, canonical_json::to_canonical_value,
events::{ events::{
StateEventType, StateEventType,
+1 -4
View File
@@ -10,10 +10,7 @@ use conduwuit::{
use futures::{FutureExt, StreamExt, pin_mut}; use futures::{FutureExt, StreamExt, pin_mut};
use ruma::{ use ruma::{
CanonicalJsonObject, CanonicalJsonValue, OwnedServerName, RoomId, UserId, CanonicalJsonObject, CanonicalJsonValue, OwnedServerName, RoomId, UserId,
api::{ api::{client::membership::leave_room, federation},
client::membership::leave_room,
federation::{self},
},
events::{ events::{
StateEventType, StateEventType,
room::member::{MembershipState, RoomMemberEventContent}, room::member::{MembershipState, RoomMemberEventContent},
+1 -1
View File
@@ -9,7 +9,7 @@ use conduwuit::{
use futures::{FutureExt, StreamExt, future::join}; use futures::{FutureExt, StreamExt, future::join};
use ruma::{ use ruma::{
api::client::membership::{ api::client::membership::{
get_member_events::{self}, get_member_events,
joined_members::{self, v3::RoomMember}, joined_members::{self, v3::RoomMember},
}, },
events::{ events::{
+1 -1
View File
@@ -77,7 +77,7 @@ struct FullCreationContent {
/// - Send events listed in initial state /// - Send events listed in initial state
/// - Send events implied by `name` and `topic` /// - Send events implied by `name` and `topic`
/// - Send invite events /// - Send invite events
#[allow(clippy::large_stack_frames)] #[allow(clippy::large_unopt_stack_frames)]
#[allow(clippy::cognitive_complexity)] #[allow(clippy::cognitive_complexity)]
pub(crate) async fn create_room_route( pub(crate) async fn create_room_route(
State(services): State<crate::State>, State(services): State<crate::State>,
+1 -2
View File
@@ -94,8 +94,7 @@ pub(crate) async fn room_initial_sync_route(
.first() .first()
.map(at!(0)) .map(at!(0))
.as_ref() .as_ref()
.map(ToString::to_string) .map_or_default(ToString::to_string);
.unwrap_or_default();
let start = events.last().map(at!(0)).as_ref().map(ToString::to_string); let start = events.last().map(at!(0)).as_ref().map(ToString::to_string);
let chunk = events let chunk = events
+1 -2
View File
@@ -787,8 +787,7 @@ async fn build_room_summary(
Ok(Some(assign!(RoomSummary::new(), { Ok(Some(assign!(RoomSummary::new(), {
heroes: heroes heroes: heroes
.map(|heroes| heroes.into_iter().collect()) .map_or_default(|heroes| heroes.into_iter().collect()),
.unwrap_or_default(),
joined_member_count: Some(ruma_from_u64(joined_member_count)), joined_member_count: Some(ruma_from_u64(joined_member_count)),
invited_member_count: Some(ruma_from_u64(invited_member_count)), invited_member_count: Some(ruma_from_u64(invited_member_count)),
}))) })))
+1 -3
View File
@@ -5,9 +5,7 @@ use conduwuit::{
}; };
use futures::{FutureExt, StreamExt, pin_mut}; use futures::{FutureExt, StreamExt, pin_mut};
use ruma::{ use ruma::{
api::client::user_directory::search_users::{self}, api::client::user_directory::search_users, assign, events::room::join_rules::JoinRule,
assign,
events::room::join_rules::JoinRule,
}; };
use crate::Ruma; use crate::Ruma;
+1 -1
View File
@@ -69,7 +69,7 @@ pub(crate) async fn create_join_event_template_route(
.get_member(&body.room_id, &body.user_id) .get_member(&body.room_id, &body.user_id)
.await .await
.ok() .ok()
.map_or_else(|| MembershipState::Leave, |content| content.membership); .map_or(MembershipState::Leave, |content| content.membership);
let join_authorized_via_users_server: Option<OwnedUserId> = { let join_authorized_via_users_server: Option<OwnedUserId> = {
if matches!( if matches!(
+1 -2
View File
@@ -76,8 +76,7 @@ impl super::Engine {
.config .config
.database_backup_path .database_backup_path
.clone() .clone()
.map(PathBuf::into_os_string) .map_or_default(PathBuf::into_os_string);
.unwrap_or_default();
if path.is_empty() { if path.is_empty() {
return Err!(Config("database_backup_path", "Configure path to enable backups")); return Err!(Config("database_backup_path", "Configure path to enable backups"));
+1 -1
View File
@@ -22,7 +22,7 @@ use hyper_util::{
use tokio::{ use tokio::{
fs, fs,
net::{UnixListener, UnixStream, unix::SocketAddr}, net::{UnixListener, UnixStream, unix::SocketAddr},
sync::broadcast::{self}, sync::broadcast,
task::JoinSet, task::JoinSet,
time::{Duration, sleep}, time::{Duration, sleep},
}; };
+1 -1
View File
@@ -379,7 +379,7 @@ fn get_dns_resolver(server: &Arc<Server>) -> Result<Arc<TokioResolver>> {
info!(?nameservers, "Resolved nameservers for DNS client"); info!(?nameservers, "Resolved nameservers for DNS client");
for sys_conf in nameservers { for sys_conf in nameservers {
let mut ns = sys_conf.clone(); let mut ns = sys_conf;
if config.query_over_tcp_only { if config.query_over_tcp_only {
ns.connections = vec![ConnectionConfig::tcp()]; ns.connections = vec![ConnectionConfig::tcp()];
+5 -30
View File
@@ -182,26 +182,11 @@ impl Data {
let mut value = Vec::<u8>::new(); let mut value = Vec::<u8>::new();
value.extend_from_slice(&timestamp.as_secs().to_be_bytes()); value.extend_from_slice(&timestamp.as_secs().to_be_bytes());
value.push(0xFF); value.push(0xFF);
value.extend_from_slice( value.extend_from_slice(data.title.as_ref().map_or_default(String::as_bytes));
data.title
.as_ref()
.map(String::as_bytes)
.unwrap_or_default(),
);
value.push(0xFF); value.push(0xFF);
value.extend_from_slice( value.extend_from_slice(data.description.as_ref().map_or_default(String::as_bytes));
data.description
.as_ref()
.map(String::as_bytes)
.unwrap_or_default(),
);
value.push(0xFF); value.push(0xFF);
value.extend_from_slice( value.extend_from_slice(data.image.as_ref().map_or_default(String::as_bytes));
data.image
.as_ref()
.map(String::as_bytes)
.unwrap_or_default(),
);
value.push(0xFF); value.push(0xFF);
value.extend_from_slice(&data.image_size.unwrap_or(0).to_be_bytes()); value.extend_from_slice(&data.image_size.unwrap_or(0).to_be_bytes());
value.push(0xFF); value.push(0xFF);
@@ -209,12 +194,7 @@ impl Data {
value.push(0xFF); value.push(0xFF);
value.extend_from_slice(&data.image_height.unwrap_or(0).to_be_bytes()); value.extend_from_slice(&data.image_height.unwrap_or(0).to_be_bytes());
value.push(0xFF); value.push(0xFF);
value.extend_from_slice( value.extend_from_slice(data.video.as_ref().map_or_default(String::as_bytes));
data.video
.as_ref()
.map(String::as_bytes)
.unwrap_or_default(),
);
value.push(0xFF); value.push(0xFF);
value.extend_from_slice(&data.video_size.unwrap_or(0).to_be_bytes()); value.extend_from_slice(&data.video_size.unwrap_or(0).to_be_bytes());
value.push(0xFF); value.push(0xFF);
@@ -222,12 +202,7 @@ impl Data {
value.push(0xFF); value.push(0xFF);
value.extend_from_slice(&data.video_height.unwrap_or(0).to_be_bytes()); value.extend_from_slice(&data.video_height.unwrap_or(0).to_be_bytes());
value.push(0xFF); value.push(0xFF);
value.extend_from_slice( value.extend_from_slice(data.audio.as_ref().map_or_default(String::as_bytes));
data.audio
.as_ref()
.map(String::as_bytes)
.unwrap_or_default(),
);
value.push(0xFF); value.push(0xFF);
value.extend_from_slice(&data.audio_size.unwrap_or(0).to_be_bytes()); value.extend_from_slice(&data.audio_size.unwrap_or(0).to_be_bytes());
+1 -1
View File
@@ -1,7 +1,7 @@
use std::{ use std::{
collections::HashSet, collections::HashSet,
ffi::{OsStr, OsString}, ffi::{OsStr, OsString},
fs::{self}, fs,
path::PathBuf, path::PathBuf,
sync::Arc, sync::Arc,
time::Instant, time::Instant,
+1
View File
@@ -1,4 +1,5 @@
#![type_length_limit = "8192"] #![type_length_limit = "8192"]
#![recursion_limit = "256"]
#![allow(refining_impl_trait)] #![allow(refining_impl_trait)]
extern crate conduwuit_core as conduwuit; extern crate conduwuit_core as conduwuit;
+1 -1
View File
@@ -153,7 +153,7 @@ impl Service {
.get_member(room_id, sender_user) .get_member(room_id, sender_user)
.await .await
.ok() .ok()
.map_or_else(|| MembershipState::Leave, |content| content.membership) .map_or(MembershipState::Leave, |content| content.membership)
} else { } else {
MembershipState::Leave MembershipState::Leave
}; };
+1 -4
View File
@@ -8,10 +8,7 @@ use conduwuit::{
utils::{self, IterStream, ReadyExt}, utils::{self, IterStream, ReadyExt},
}; };
use database::{Deserialized, Get, Map, Qry}; use database::{Deserialized, Get, Map, Qry};
use futures::{ use futures::{Stream, StreamExt, stream};
Stream, StreamExt,
stream::{self},
};
use ruma::{EventId, OwnedEventId, RoomId, events::StateEventType}; use ruma::{EventId, OwnedEventId, RoomId, events::StateEventType};
use serde::Deserialize; use serde::Deserialize;
+5 -8
View File
@@ -264,14 +264,11 @@ impl Service {
.compress_state_event(shortstatekey, &new_pdu.event_id) .compress_state_event(shortstatekey, &new_pdu.event_id)
.await; .await;
let replaces = states_parents let replaces = states_parents.last().map_or_default(|info| {
.last() info.full_state
.map(|info| { .iter()
info.full_state .find(|bytes| bytes.starts_with(&shortstatekey.to_be_bytes()))
.iter() });
.find(|bytes| bytes.starts_with(&shortstatekey.to_be_bytes()))
})
.unwrap_or_default();
if Some(&new) == replaces { if Some(&new) == replaces {
return Ok(previous_shortstatehash.expect("must exist")); return Ok(previous_shortstatehash.expect("must exist"));
+1 -1
View File
@@ -745,7 +745,7 @@ impl Service {
.get_member(room_id, querying_user) .get_member(room_id, querying_user)
.await .await
.ok() .ok()
.map_or_else(|| MembershipState::Leave, |content| content.membership); .map_or(MembershipState::Leave, |content| content.membership);
if matches!(membership, MembershipState::Join | MembershipState::Invite) { if matches!(membership, MembershipState::Join | MembershipState::Invite) {
return true; return true;
+1 -6
View File
@@ -1,10 +1,5 @@
use conduwuit::config::experiments::ToggledExperiment; use conduwuit::config::experiments::ToggledExperiment;
use conduwuit_core::{ use conduwuit_core::{Err, Result, err, matrix::event::Event, utils, warn};
Err, Result, err,
matrix::event::Event,
utils::{self},
warn,
};
use ruma::{EventId, events::room::encrypted::Relation, signatures::content_hash}; use ruma::{EventId, events::room::encrypted::Relation, signatures::content_hash};
use super::{ExtractBody, ExtractRelatesTo}; use super::{ExtractBody, ExtractRelatesTo};
+1 -2
View File
@@ -101,8 +101,7 @@ impl super::Service {
.trusted_servers .trusted_servers
.iter() .iter()
.find(|n| n.server_name() == notary) .find(|n| n.server_name() == notary)
.map(|nk| nk.verify_keys().to_owned()) .map_or_default(|nk| nk.verify_keys().to_owned());
.unwrap_or_default();
let keys = self let keys = self
.services .services
.sending .sending
+1 -1
View File
@@ -143,7 +143,7 @@ impl Service {
) { ) {
let mut key = user_id.as_bytes().to_vec(); let mut key = user_id.as_bytes().to_vec();
key.push(0xFF); key.push(0xFF);
key.extend_from_slice(device_id.map(DeviceId::as_bytes).unwrap_or_default()); key.extend_from_slice(device_id.map_or_default(DeviceId::as_bytes));
key.push(0xFF); key.push(0xFF);
key.extend_from_slice(txn_id.as_bytes()); key.extend_from_slice(txn_id.as_bytes());
+1 -4
View File
@@ -9,10 +9,7 @@ pub(super) mod remote;
use std::{mem, sync::Arc}; use std::{mem, sync::Arc};
pub use account::{AccessTokenStatus, AccountStatus}; pub use account::{AccessTokenStatus, AccountStatus};
use conduwuit::{ use conduwuit::{Err, Error, Result, err, utils};
Err, Error, Result, err,
utils::{self},
};
use database::Map; use database::Map;
pub use device::DeviceToken; pub use device::DeviceToken;
pub use profile::ProfileFieldChange; pub use profile::ProfileFieldChange;