resolve and add even more pedantic clippy lints

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-03-22 22:44:31 -04:00 committed by June
parent 0bb5115bd1
commit 3bc2af7d26
32 changed files with 167 additions and 167 deletions

View file

@ -790,12 +790,12 @@ impl Service {
"Deleted {} total MXCs from our database and the filesystem from event ID {event_id}.",
mxc_deletion_count
)));
} else {
return Ok(RoomMessageEventContent::text_plain(
"Please specify either an MXC using --mxc or an event ID using --event-id of the \
message containing an image. See --help for details.",
));
}
return Ok(RoomMessageEventContent::text_plain(
"Please specify either an MXC using --mxc or an event ID using --event-id of the message \
containing an image. See --help for details.",
));
},
MediaCommand::DeleteList => {
if body.len() > 2 && body[0].trim().starts_with("```") && body.last().unwrap().trim() == "```" {
@ -814,11 +814,11 @@ impl Service {
filesystem.",
mxc_deletion_count
)));
} else {
return Ok(RoomMessageEventContent::text_plain(
"Expected code block in command body. Add --help for details.",
));
}
return Ok(RoomMessageEventContent::text_plain(
"Expected code block in command body. Add --help for details.",
));
},
MediaCommand::DeletePastRemoteMedia {
duration,
@ -1322,12 +1322,12 @@ impl Service {
ignoring error and logging here: {e}"
);
continue;
} else {
return Ok(RoomMessageEventContent::text_plain(format!(
"{room_id} is not a valid room ID, please fix the list and try \
again: {e}"
)));
}
return Ok(RoomMessageEventContent::text_plain(format!(
"{room_id} is not a valid room ID, please fix the list and try again: \
{e}"
)));
},
}
}
@ -1415,17 +1415,16 @@ impl Service {
disabled incoming federation with the room.",
room_ban_count
)));
} else {
return Ok(RoomMessageEventContent::text_plain(format!(
"Finished bulk room ban, banned {} total rooms and evicted all users.",
room_ban_count
)));
}
} else {
return Ok(RoomMessageEventContent::text_plain(
"Expected code block in command body. Add --help for details.",
));
return Ok(RoomMessageEventContent::text_plain(format!(
"Finished bulk room ban, banned {} total rooms and evicted all users.",
room_ban_count
)));
}
return Ok(RoomMessageEventContent::text_plain(
"Expected code block in command body. Add --help for details.",
));
},
RoomModeration::UnbanRoom {
room,
@ -1856,7 +1855,7 @@ impl Service {
let pub_key_map = pub_key_map.read().await;
match ruma::signatures::verify_json(&pub_key_map, &value) {
Ok(_) => RoomMessageEventContent::text_plain("Signature correct"),
Ok(()) => RoomMessageEventContent::text_plain("Signature correct"),
Err(e) => RoomMessageEventContent::text_plain(format!(
"Signature verification failed: {e}"
)),
@ -1913,7 +1912,7 @@ impl Service {
}
let mut result = tokio::task::spawn_blocking(move || match services().globals.db.backup() {
Ok(_) => String::new(),
Ok(()) => String::new(),
Err(e) => (*e).to_string(),
})
.await
@ -2040,7 +2039,7 @@ impl Service {
.send_federation_request(
&server,
ruma::api::federation::event::get_event::v1::Request {
event_id: event_id.to_owned().into(),
event_id: event_id.clone().into(),
},
)
.await
@ -2208,7 +2207,7 @@ impl Service {
if let Some(line_index) = text_lines.iter().position(|line| *line == "[commandbody]") {
text_lines.remove(line_index);
while text_lines.get(line_index).map(|line| line.starts_with('#')).unwrap_or(false) {
while text_lines.get(line_index).is_some_and(|line| line.starts_with('#')) {
command_body += if text_lines[line_index].starts_with("# ") {
&text_lines[line_index][2..]
} else {
@ -2293,7 +2292,7 @@ impl Service {
event_type: TimelineEventType::RoomCreate,
content: to_raw_value(&content).expect("event is valid, we just created it"),
unsigned: None,
state_key: Some("".to_owned()),
state_key: Some(String::new()),
redacts: None,
},
&conduit_user,
@ -2346,7 +2345,7 @@ impl Service {
})
.expect("event is valid, we just created it"),
unsigned: None,
state_key: Some("".to_owned()),
state_key: Some(String::new()),
redacts: None,
},
&conduit_user,
@ -2365,7 +2364,7 @@ impl Service {
content: to_raw_value(&RoomJoinRulesEventContent::new(JoinRule::Invite))
.expect("event is valid, we just created it"),
unsigned: None,
state_key: Some("".to_owned()),
state_key: Some(String::new()),
redacts: None,
},
&conduit_user,
@ -2384,7 +2383,7 @@ impl Service {
content: to_raw_value(&RoomHistoryVisibilityEventContent::new(HistoryVisibility::Shared))
.expect("event is valid, we just created it"),
unsigned: None,
state_key: Some("".to_owned()),
state_key: Some(String::new()),
redacts: None,
},
&conduit_user,
@ -2403,7 +2402,7 @@ impl Service {
content: to_raw_value(&RoomGuestAccessEventContent::new(GuestAccess::Forbidden))
.expect("event is valid, we just created it"),
unsigned: None,
state_key: Some("".to_owned()),
state_key: Some(String::new()),
redacts: None,
},
&conduit_user,
@ -2423,7 +2422,7 @@ impl Service {
content: to_raw_value(&RoomNameEventContent::new(room_name))
.expect("event is valid, we just created it"),
unsigned: None,
state_key: Some("".to_owned()),
state_key: Some(String::new()),
redacts: None,
},
&conduit_user,
@ -2443,7 +2442,7 @@ impl Service {
})
.expect("event is valid, we just created it"),
unsigned: None,
state_key: Some("".to_owned()),
state_key: Some(String::new()),
redacts: None,
},
&conduit_user,
@ -2469,7 +2468,7 @@ impl Service {
})
.expect("event is valid, we just created it"),
unsigned: None,
state_key: Some("".to_owned()),
state_key: Some(String::new()),
redacts: None,
},
&conduit_user,
@ -2579,7 +2578,7 @@ impl Service {
})
.expect("event is valid, we just created it"),
unsigned: None,
state_key: Some("".to_owned()),
state_key: Some(String::new()),
redacts: None,
},
&conduit_user,

View file

@ -367,7 +367,7 @@ impl Service {
// The original create event must be in the auth events
if !matches!(
auth_events.get(&(StateEventType::RoomCreate, "".to_owned())).map(AsRef::as_ref),
auth_events.get(&(StateEventType::RoomCreate, String::new())).map(AsRef::as_ref),
Some(_) | None
) {
return Err(Error::BadRequest(

View file

@ -713,7 +713,7 @@ fn is_accessable_child_recurse(
return Ok(true);
}
},
_ => (),
Identifier::None => (),
} // Takes care of joinrules
Ok(match join_rule {
SpaceRoomJoinRule::KnockRestricted | SpaceRoomJoinRule::Restricted => {
@ -734,6 +734,7 @@ fn is_accessable_child_recurse(
false
},
SpaceRoomJoinRule::Public | SpaceRoomJoinRule::Knock => true,
#[allow(clippy::match_same_arms)]
SpaceRoomJoinRule::Invite | SpaceRoomJoinRule::Private => false,
// Custom join rule
_ => false,
@ -828,7 +829,7 @@ fn allowed_room_ids(join_rule: JoinRule) -> Vec<OwnedRoomId> {
room_id: membership,
}) = rule
{
room_ids.push(membership.to_owned());
room_ids.push(membership.clone());
}
}
}

View file

@ -9,7 +9,7 @@ pub trait Data: Send + Sync {
/// Returns the last state hash key added to the db for the given room.
fn get_room_shortstatehash(&self, room_id: &RoomId) -> Result<Option<u64>>;
/// Set the state hash to a new version, but does not update state_cache.
/// Set the state hash to a new version, but does not update `state_cache`.
fn set_room_state(
&self,
room_id: &RoomId,
@ -20,7 +20,7 @@ pub trait Data: Send + Sync {
/// Associates a state with an event.
fn set_event_state(&self, shorteventid: u64, shortstatehash: u64) -> Result<()>;
/// Returns all events we would send as the prev_events of the next event.
/// Returns all events we would send as the `prev_events` of the next event.
fn get_forward_extremities(&self, room_id: &RoomId) -> Result<HashSet<Arc<EventId>>>;
/// Replace the forward extremities of the room.

View file

@ -230,9 +230,7 @@ impl Service {
pub fn get_name(&self, room_id: &RoomId) -> Result<Option<String>> {
services().rooms.state_accessor.room_state_get(room_id, &StateEventType::RoomName, "")?.map_or(Ok(None), |s| {
Ok(serde_json::from_str(s.content.get())
.map(|c: RoomNameEventContent| Some(c.name))
.unwrap_or_else(|_| None))
Ok(serde_json::from_str(s.content.get()).map_or_else(|_| None, |c: RoomNameEventContent| Some(c.name)))
})
}

View file

@ -680,7 +680,7 @@ impl Service {
&mut pdu_json,
&room_version_id,
) {
Ok(_) => {},
Ok(()) => {},
Err(e) => {
return match e {
ruma::signatures::Error::PduSize => {

View file

@ -490,11 +490,9 @@ impl Service {
.to_room_event(),
);
},
SendingEventType::Edu(_) => {
// Appservices don't need EDUs (?)
},
SendingEventType::Flush => {
// flush only; no new content
SendingEventType::Edu(_) | SendingEventType::Flush => {
// Appservices don't need EDUs (?) and flush only;
// no new content
},
}
}
@ -554,11 +552,9 @@ impl Service {
})?,
);
},
SendingEventType::Edu(_) => {
// Push gateways don't need EDUs (?)
},
SendingEventType::Flush => {
// flush only; no new content
SendingEventType::Edu(_) | SendingEventType::Flush => {
// Push gateways don't need EDUs (?) and flush only;
// no new content
},
}
}