fix and enable collapsible_if lint

Signed-off-by: June Strawberry <june@vern.cc>
This commit is contained in:
June Strawberry
2026-01-15 17:39:33 -05:00
parent fb102f0e0a
commit 04e66a03d3
54 changed files with 453 additions and 504 deletions

View File

@@ -35,10 +35,10 @@ async fn destinations_cache(&self, server_name: Option<OwnedServerName>) -> Resu
.boxed();
while let Some((name, CachedDest { dest, host, expire })) = destinations.next().await {
if let Some(server_name) = server_name.as_ref() {
if name != server_name {
continue;
}
if let Some(server_name) = server_name.as_ref()
&& name != server_name
{
continue;
}
let expire = time::format(expire, "%+");
@@ -61,10 +61,10 @@ async fn overrides_cache(&self, server_name: Option<String>) -> Result {
while let Some((name, CachedOverride { ips, port, expire, overriding })) =
overrides.next().await
{
if let Some(server_name) = server_name.as_ref() {
if name != server_name {
continue;
}
if let Some(server_name) = server_name.as_ref()
&& name != server_name
{
continue;
}
let expire = time::format(expire, "%+");

View File

@@ -50,10 +50,10 @@ async fn ban_room(&self, room: OwnedRoomOrAliasId) -> Result {
let admin_room_alias = &self.services.admin.admin_alias;
if let Ok(admin_room_id) = self.services.admin.get_admin_room().await {
if room.to_string().eq(&admin_room_id) || room.to_string().eq(admin_room_alias) {
return Err!("Not allowed to ban the admin room.");
}
if let Ok(admin_room_id) = self.services.admin.get_admin_room().await
&& (room.to_string().eq(&admin_room_id) || room.to_string().eq(admin_room_alias))
{
return Err!("Not allowed to ban the admin room.");
}
let room_id = if room.is_room_id() {
@@ -217,12 +217,12 @@ async fn ban_list_of_rooms(&self) -> Result {
for &room in &rooms_s {
match <&RoomOrAliasId>::try_from(room) {
| Ok(room_alias_or_id) => {
if let Ok(admin_room_id) = self.services.admin.get_admin_room().await {
if room.to_owned().eq(&admin_room_id) || room.to_owned().eq(admin_room_alias)
{
warn!("User specified admin room in bulk ban list, ignoring");
continue;
}
if let Ok(admin_room_id) = self.services.admin.get_admin_room().await
&& (room.to_owned().eq(&admin_room_id)
|| room.to_owned().eq(admin_room_alias))
{
warn!("User specified admin room in bulk ban list, ignoring");
continue;
}
if room_alias_or_id.is_room_id() {

View File

@@ -49,10 +49,10 @@ pub(super) async fn create_user(&self, username: String, password: Option<String
// Validate user id
let user_id = parse_local_user_id(self.services, &username)?;
if let Err(e) = user_id.validate_strict() {
if self.services.config.emergency_password.is_none() {
return Err!("Username {user_id} contains disallowed characters or spaces: {e}");
}
if let Err(e) = user_id.validate_strict()
&& self.services.config.emergency_password.is_none()
{
return Err!("Username {user_id} contains disallowed characters or spaces: {e}");
}
if self.services.users.exists(&user_id).await {