Use #[expect], lint reasons

This commit is contained in:
Lambda 2024-09-05 19:01:22 +00:00
parent e14b7f28f2
commit b09c44a0ca
49 changed files with 157 additions and 161 deletions

View file

@ -85,7 +85,7 @@ pub(crate) async fn get_register_available_route(
/// - Creates a new account and populates it with default account data
/// - If `inhibit_login` is false: Creates a device and returns `device_id` and
/// `access_token`
#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
pub(crate) async fn register_route(
body: Ar<register::v3::Request>,
) -> Result<Ra<register::v3::Response>> {

View file

@ -17,7 +17,7 @@ use crate::{services, Ar, Error, Ra, Result};
///
/// - Only works if the user is joined (TODO: always allow, but only show events
/// if the user was joined, depending on `history_visibility`)
#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
pub(crate) async fn get_context_route(
body: Ar<get_context::v3::Request>,
) -> Result<Ra<get_context::v3::Response>> {

View file

@ -137,7 +137,7 @@ pub(crate) async fn get_room_visibility_route(
}))
}
#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
pub(crate) async fn get_public_rooms_filtered_helper(
server: Option<&ServerName>,
limit: Option<UInt>,
@ -267,7 +267,6 @@ pub(crate) async fn get_public_rooms_filtered_helper(
})
}
#[allow(clippy::too_many_lines)]
#[tracing::instrument]
fn room_id_to_chunk(room_id: ruma::OwnedRoomId) -> Result<PublicRoomsChunk> {
let canonical_alias = services()

View file

@ -284,7 +284,7 @@ pub(crate) async fn get_key_changes_route(
}))
}
#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
pub(crate) async fn get_keys_helper<F: Fn(&UserId) -> bool>(
sender_user: Option<&UserId>,
device_keys_input: &BTreeMap<OwnedUserId, Vec<OwnedDeviceId>>,

View file

@ -124,7 +124,7 @@ fn set_header_or_panic(
/// # `GET /_matrix/media/r0/config`
///
/// Returns max upload size.
#[allow(deprecated)] // unauthenticated media
#[expect(deprecated, reason = "legacy media APIs")]
pub(crate) async fn get_media_config_legacy_route(
_body: Ar<legacy_media::get_media_config::v3::Request>,
) -> Result<Ra<legacy_media::get_media_config::v3::Response>> {
@ -196,7 +196,7 @@ impl From<bool> for AllowRemote {
}
struct RemoteResponse {
#[allow(unused)]
#[expect(unused, reason = "placeholder for future spec changes")]
metadata: authenticated_media_fed::ContentMetadata,
content: authenticated_media_fed::Content,
}
@ -290,7 +290,7 @@ async fn get_remote_content_via_federation_api(
})
}
#[allow(deprecated)] // unauthenticated media
#[expect(deprecated, reason = "legacy media APIs")]
#[tracing::instrument(skip_all)]
async fn get_remote_content_via_legacy_api(
mxc: &MxcData<'_>,
@ -365,7 +365,7 @@ pub(crate) async fn get_remote_content(
/// Load media from our server or over federation.
///
/// - Only allows federation if `allow_remote` is true
#[allow(deprecated)] // unauthenticated media
#[expect(deprecated, reason = "legacy media APIs")]
pub(crate) async fn get_content_legacy_route(
body: Ar<legacy_media::get_content::v3::Request>,
) -> Result<axum::response::Response> {
@ -487,7 +487,7 @@ async fn get_content_route_ruma(
/// Load media from our server or over federation, permitting desired filename.
///
/// - Only allows federation if `allow_remote` is true
#[allow(deprecated)] // unauthenticated media
#[expect(deprecated, reason = "legacy media APIs")]
pub(crate) async fn get_content_as_filename_legacy_route(
body: Ar<legacy_media::get_content_as_filename::v3::Request>,
) -> Result<axum::response::Response> {
@ -632,7 +632,7 @@ fn fix_thumbnail_headers(r: &mut axum::response::Response) {
/// Load media thumbnail from our server or over federation.
///
/// - Only allows federation if `allow_remote` is true
#[allow(deprecated)] // unauthenticated media
#[expect(deprecated, reason = "legacy media APIs")]
pub(crate) async fn get_content_thumbnail_legacy_route(
body: Ar<legacy_media::get_content_thumbnail::v3::Request>,
) -> Result<axum::response::Response> {
@ -741,7 +741,7 @@ async fn get_remote_thumbnail_via_federation_api(
})
}
#[allow(deprecated)] // unauthenticated media
#[expect(deprecated, reason = "legacy media APIs")]
#[tracing::instrument(skip_all)]
async fn get_remote_thumbnail_via_legacy_api(
server_name: &ruma::ServerName,

View file

@ -499,7 +499,6 @@ pub(crate) async fn joined_members_route(
}))
}
#[allow(clippy::too_many_lines)]
#[tracing::instrument(skip(reason, _third_party_signed))]
async fn join_room_by_id_helper(
sender_user: Option<&UserId>,
@ -1265,7 +1264,7 @@ async fn validate_and_add_event_id(
Ok((event_id, value))
}
#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
pub(crate) async fn invite_helper(
sender_user: &UserId,
user_id: &UserId,
@ -1571,7 +1570,7 @@ pub(crate) async fn leave_room(
Ok(())
}
#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
async fn remote_leave_room(user_id: &UserId, room_id: &RoomId) -> Result<()> {
let mut make_leave_response_and_server = Err(Error::BadServerResponse(
"No server available to assist in leaving.",

View file

@ -118,7 +118,7 @@ pub(crate) async fn send_message_event_route(
///
/// - Only works if the user is joined (TODO: always allow, but only show events
/// where the user was joined, depending on `history_visibility`)
#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
pub(crate) async fn get_message_events_route(
body: Ar<get_message_events::v3::Request>,
) -> Result<Ra<get_message_events::v3::Response>> {

View file

@ -50,7 +50,7 @@ use crate::{
/// - Send events listed in initial state
/// - Send events implied by `name` and `topic`
/// - Send invite events
#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
pub(crate) async fn create_room_route(
body: Ar<create_room::v3::Request>,
) -> Result<Ra<create_room::v3::Response>> {
@ -570,7 +570,7 @@ pub(crate) async fn get_room_aliases_route(
/// - Transfers some state events
/// - Moves local aliases
/// - Modifies old room power levels to prevent users from speaking
#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
pub(crate) async fn upgrade_room_route(
body: Ar<upgrade_room::v3::Request>,
) -> Result<Ra<upgrade_room::v3::Response>> {

View file

@ -22,7 +22,7 @@ use crate::{services, Ar, Error, Ra, Result};
///
/// - Only works if the user is currently joined to the room (TODO: Respect
/// history visibility)
#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
pub(crate) async fn search_events_route(
body: Ar<search_events::v3::Request>,
) -> Result<Ra<search_events::v3::Response>> {

View file

@ -51,11 +51,8 @@ pub(crate) async fn get_login_types_route(
///
/// Note: You can use [`GET /_matrix/client/r0/login`](get_login_types_route) to
/// see supported login types.
#[allow(
// To allow deprecated login methods
deprecated,
clippy::too_many_lines,
)]
#[expect(deprecated, reason = "To allow deprecated login methods")]
#[expect(clippy::too_many_lines)]
pub(crate) async fn login_route(
body: Ar<login::v3::Request>,
) -> Result<Ra<login::v3::Response>> {
@ -252,8 +249,6 @@ pub(crate) async fn login_route(
info!(%user_id, %device_id, "User logged in");
// Homeservers are still required to send the `home_server` field
#[allow(deprecated)]
Ok(Ra(login::v3::Response {
user_id,
access_token: token,

View file

@ -67,7 +67,7 @@ use crate::{
/// For left rooms:
/// - If the user left after `since`: `prev_batch` token, empty state (TODO:
/// subset of the state at the point of the leave)
#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
pub(crate) async fn sync_events_route(
body: Ar<sync_events::v3::Request>,
) -> Result<Ra<sync_events::v3::Response>, Ra<UiaaResponse>> {
@ -449,7 +449,7 @@ pub(crate) async fn sync_events_route(
}
#[tracing::instrument(skip_all, fields(room_id = %room_id))]
#[allow(clippy::too_many_arguments, clippy::too_many_lines)]
#[expect(clippy::too_many_arguments)]
async fn load_joined_room(
sender_user: &UserId,
sender_device: &DeviceId,
@ -1121,7 +1121,7 @@ fn share_encrypted_room(
.any(|encrypted| encrypted))
}
#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
pub(crate) async fn sync_events_v4_route(
body: Ar<sync_events::v4::Request>,
) -> Result<Ra<sync_events::v4::Response>, Ra<UiaaResponse>> {

View file

@ -50,7 +50,7 @@ struct ArPieces {
/// Non-generic part of [`Ar::from_request()`]. Splitting this out reduces
/// binary size by ~10%.
#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
async fn ar_from_request_inner(
req: axum::extract::Request,
metadata: Metadata,

View file

@ -372,7 +372,6 @@ fn add_port_to_hostname(destination_str: &str) -> FedDest {
/// Implemented according to the specification at <https://matrix.org/docs/spec/server_server/r0.1.4#resolving-server-names>
/// Numbers in comments below refer to bullet points in linked section of
/// specification
#[allow(clippy::too_many_lines)]
#[tracing::instrument(ret(level = "debug"))]
async fn find_actual_destination(
destination: &'_ ServerName,
@ -729,7 +728,7 @@ pub(crate) fn parse_incoming_pdu(
/// # `PUT /_matrix/federation/v1/send/{txnId}`
///
/// Push EDUs and PDUs to this server.
#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
pub(crate) async fn send_transaction_message_route(
body: Ar<send_transaction_message::v1::Request>,
) -> Result<Ra<send_transaction_message::v1::Response>> {
@ -1561,7 +1560,7 @@ pub(crate) async fn create_join_event_template_route(
}))
}
#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
async fn create_join_event(
sender_servername: &ServerName,
room_id: &RoomId,
@ -1706,7 +1705,7 @@ async fn create_join_event(
/// # `PUT /_matrix/federation/v1/send_join/{roomId}/{eventId}`
///
/// Submits a signed join event.
#[allow(deprecated)]
#[expect(deprecated, reason = "support for deprecated API")]
pub(crate) async fn create_join_event_v1_route(
body: Ar<create_join_event::v1::Request>,
) -> Result<Ra<create_join_event::v1::Response>> {
@ -1750,7 +1749,7 @@ pub(crate) async fn create_join_event_v2_route(
/// # `PUT /_matrix/federation/v2/invite/{roomId}/{eventId}`
///
/// Invites a remote user to a room.
#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
pub(crate) async fn create_invite_route(
body: Ar<create_invite::v2::Request>,
) -> Result<Ra<create_invite::v2::Response>> {