Replace clippy allow annotation with expect (fixes #5012) (#5048)

This commit is contained in:
Nutomic 2024-09-24 19:29:02 +02:00 committed by GitHub
parent 61a02482ff
commit f6a24e133a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
60 changed files with 59 additions and 111 deletions

View file

@ -265,8 +265,6 @@ pub async fn local_user_view_from_jwt(
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
mod tests {
use super::*;

View file

@ -34,7 +34,7 @@ use lemmy_db_views::structs::LocalUserView;
use lemmy_utils::{error::LemmyResult, LemmyErrorType, CACHE_DURATION_API};
use serial_test::serial;
#[allow(clippy::unwrap_used)]
#[expect(clippy::unwrap_used)]
async fn create_test_site(context: &Data<LemmyContext>) -> LemmyResult<(Instance, LocalUserView)> {
let pool = &mut context.pool();
@ -109,7 +109,7 @@ async fn signup(
Ok((local_user, application))
}
#[allow(clippy::unwrap_used)]
#[expect(clippy::unwrap_used)]
async fn get_application_statuses(
context: &Data<LemmyContext>,
admin: LocalUserView,
@ -138,10 +138,9 @@ async fn get_application_statuses(
Ok((application_count, unread_applications, all_applications))
}
#[allow(clippy::indexing_slicing)]
#[allow(clippy::unwrap_used)]
#[tokio::test]
#[serial]
#[tokio::test]
#[expect(clippy::indexing_slicing)]
async fn test_application_approval() -> LemmyResult<()> {
let context = LemmyContext::init_test_context().await;
let pool = &mut context.pool();

View file

@ -42,7 +42,7 @@ pub async fn get_sitemap(context: Data<LemmyContext>) -> LemmyResult<HttpRespons
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[expect(clippy::unwrap_used)]
pub(crate) mod tests {
use crate::sitemap::generate_urlset;

View file

@ -69,8 +69,7 @@ impl Claims {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {
use crate::{claims::Claims, context::LemmyContext};

View file

@ -471,8 +471,7 @@ pub async fn replace_image(
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {
use crate::{

View file

@ -1067,8 +1067,7 @@ fn build_proxied_image_url(
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {
use super::*;

View file

@ -189,8 +189,6 @@ fn validate_create_payload(local_site: &LocalSite, create_site: &CreateSite) ->
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
mod tests {
use crate::site::create::validate_create_payload;

View file

@ -48,8 +48,6 @@ fn not_zero(val: Option<i32>) -> Option<i32> {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
mod tests {
use crate::site::{application_question_check, not_zero, site_default_post_listing_type_check};

View file

@ -241,8 +241,6 @@ fn validate_update_payload(local_site: &LocalSite, edit_site: &EditSite) -> Lemm
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
mod tests {
use crate::site::update::validate_update_payload;

View file

@ -123,7 +123,6 @@ impl InCommunity for AnnouncableActivities {
}
#[cfg(test)]
#[allow(clippy::indexing_slicing)]
mod tests {
use crate::{

View file

@ -307,8 +307,9 @@ where
});
Ok(failed_items.into_iter().join(","))
}
#[cfg(test)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::indexing_slicing)]
mod tests {
use crate::api::user_settings_backup::{export_settings, import_settings, UserSettingsBackup};

View file

@ -98,7 +98,7 @@ impl Collection for ApubCommunityModerators {
}
#[cfg(test)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::indexing_slicing)]
mod tests {
use super::*;

View file

@ -120,8 +120,7 @@ pub(crate) async fn get_apub_community_featured(
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
pub(crate) mod tests {
use super::*;

View file

@ -75,7 +75,7 @@ impl<S: ValidGrouping<(), IsAggregate = is_aggregate::No>> ValidGrouping<()>
type IsAggregate = is_aggregate::No;
}
#[allow(non_camel_case_types)]
#[expect(non_camel_case_types)]
#[derive(QueryId, Clone, Copy, Debug)]
pub struct current_value;

View file

@ -30,8 +30,7 @@ impl CommentAggregates {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {
use crate::{

View file

@ -36,8 +36,7 @@ impl CommunityAggregates {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {
use crate::{

View file

@ -20,8 +20,7 @@ impl PersonAggregates {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {
use crate::{

View file

@ -49,8 +49,8 @@ impl PostAggregates {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {
use crate::{

View file

@ -15,8 +15,8 @@ impl SiteAggregates {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {
use crate::{

View file

@ -58,8 +58,7 @@ impl ReceivedActivity {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {
use super::*;

View file

@ -392,8 +392,8 @@ async fn convert_read_languages(
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
#[expect(clippy::indexing_slicing)]
mod tests {
use super::*;

View file

@ -51,8 +51,6 @@ impl CaptchaAnswer {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
mod tests {
use crate::{

View file

@ -196,8 +196,7 @@ impl Saveable for CommentSaved {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {
use crate::{

View file

@ -431,7 +431,6 @@ impl ApubActor for Community {
}
#[cfg(test)]
#[allow(clippy::indexing_slicing)]
mod tests {
use crate::{
source::{

View file

@ -48,8 +48,7 @@ impl FederationAllowList {
}
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {
use crate::{

View file

@ -41,8 +41,8 @@ impl Language {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
#[expect(clippy::indexing_slicing)]
mod tests {
use crate::{source::language::Language, utils::build_db_pool_for_tests};

View file

@ -369,7 +369,6 @@ pub struct UserBackupLists {
}
#[cfg(test)]
#[allow(clippy::indexing_slicing)]
mod tests {
use crate::{
source::{

View file

@ -465,8 +465,7 @@ impl Crud for AdminPurgeComment {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {
use crate::{

View file

@ -42,8 +42,6 @@ impl PasswordResetRequest {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
mod tests {
use crate::{

View file

@ -235,7 +235,6 @@ impl PersonFollower {
}
#[cfg(test)]
#[allow(clippy::indexing_slicing)]
mod tests {
use crate::{

View file

@ -392,8 +392,7 @@ impl PostHide {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {
use crate::{

View file

@ -80,8 +80,7 @@ impl Reportable for PostReport {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {
use super::*;

View file

@ -85,8 +85,7 @@ impl PrivateMessage {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {
use crate::{

View file

@ -27,7 +27,6 @@ pub mod newtypes;
pub mod sensitive;
#[cfg(feature = "full")]
#[rustfmt::skip]
#[allow(clippy::wildcard_imports)]
pub mod schema;
#[cfg(feature = "full")]
pub mod aliases {

View file

@ -191,13 +191,13 @@ impl Display for DbUrl {
}
// the project doesn't compile with From
#[allow(clippy::from_over_into)]
#[expect(clippy::from_over_into)]
impl Into<DbUrl> for Url {
fn into(self) -> DbUrl {
DbUrl(Box::new(self))
}
}
#[allow(clippy::from_over_into)]
#[expect(clippy::from_over_into)]
impl Into<Url> for DbUrl {
fn into(self) -> Url {
*self.0

View file

@ -595,7 +595,6 @@ impl<RF, LF> Queries<RF, LF> {
}
#[cfg(test)]
#[allow(clippy::indexing_slicing)]
mod tests {
use super::*;

View file

@ -259,8 +259,8 @@ impl CommentReportQuery {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
#[expect(clippy::indexing_slicing)]
mod tests {
use crate::{

View file

@ -422,8 +422,8 @@ impl<'a> CommentQuery<'a> {
}
#[cfg(test)]
#[allow(clippy::indexing_slicing)]
#[allow(clippy::unwrap_used)]
#[expect(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {
use crate::{

View file

@ -284,8 +284,8 @@ impl PostReportQuery {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
#[expect(clippy::indexing_slicing)]
mod tests {
use crate::{

View file

@ -739,7 +739,7 @@ impl<'a> PostQuery<'a> {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[expect(clippy::unwrap_used)]
mod tests {
use crate::{
post_view::{PaginationCursorData, PostQuery, PostView},

View file

@ -111,8 +111,8 @@ impl PrivateMessageReportQuery {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
#[expect(clippy::indexing_slicing)]
mod tests {
use crate::private_message_report_view::PrivateMessageReportQuery;

View file

@ -173,8 +173,8 @@ impl PrivateMessageQuery {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
#[expect(clippy::indexing_slicing)]
mod tests {
use crate::{private_message_view::PrivateMessageQuery, structs::PrivateMessageView};

View file

@ -135,8 +135,7 @@ impl RegistrationApplicationQuery {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {
use crate::registration_application_view::{

View file

@ -83,8 +83,7 @@ impl VoteView {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {
use crate::structs::VoteView;

View file

@ -303,7 +303,6 @@ impl CommentReplyQuery {
}
#[cfg(test)]
#[allow(clippy::indexing_slicing)]
mod tests {
use crate::{comment_reply_view::CommentReplyQuery, structs::CommentReplyView};

View file

@ -248,8 +248,7 @@ impl<'a> CommunityQuery<'a> {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {
use crate::{community_view::CommunityQuery, structs::CommunityView};

View file

@ -303,7 +303,6 @@ impl PersonMentionQuery {
}
#[cfg(test)]
#[allow(clippy::indexing_slicing)]
mod tests {
use crate::{person_mention_view::PersonMentionQuery, structs::PersonMentionView};

View file

@ -164,7 +164,7 @@ impl PersonQuery {
}
#[cfg(test)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::indexing_slicing)]
mod tests {
use super::*;

View file

@ -222,8 +222,8 @@ impl<T: DataSource> CommunityInboxCollector<T> {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
#[expect(clippy::indexing_slicing)]
mod tests {
use super::*;
use lemmy_db_schema::{

View file

@ -192,8 +192,8 @@ impl SendManager {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
#[expect(clippy::indexing_slicing)]
mod test {
use super::*;

View file

@ -439,8 +439,8 @@ impl InstanceWorker {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
#[expect(clippy::indexing_slicing)]
mod test {
use super::*;

View file

@ -221,8 +221,6 @@ fn parse_ip(addr: &str) -> Option<IpAddr> {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
mod tests {
#[test]

View file

@ -136,7 +136,6 @@ impl<K: Eq + Hash, C: MapLevel> MapLevel for Map<K, C> {
.entry(addr_part)
.or_insert(RateLimitedGroup::new(now, adjusted_configs));
#[allow(clippy::indexing_slicing)]
let total_passes = group.check_total(action_type, now, adjusted_configs[action_type]);
let children_pass = group.children.check(
@ -161,7 +160,6 @@ impl<K: Eq + Hash, C: MapLevel> MapLevel for Map<K, C> {
// Evaluated if `some_children_remaining` is false
let total_has_refill_in_future = || {
group.total.into_iter().any(|(action_type, bucket)| {
#[allow(clippy::indexing_slicing)]
let config = configs[action_type];
bucket.update(now, config).tokens != config.capacity
})
@ -214,7 +212,6 @@ impl<C: Default> RateLimitedGroup<C> {
now: InstantSecs,
config: BucketConfig,
) -> bool {
#[allow(clippy::indexing_slicing)] // `EnumMap` has no `get` function
let bucket = &mut self.total[action_type];
let new_bucket = bucket.update(now, config);
@ -311,8 +308,7 @@ fn split_ipv6(ip: Ipv6Addr) -> ([u8; 6], u8, u8) {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {
use super::{ActionType, BucketConfig, InstantSecs, RateLimitState, RateLimitedGroup};
@ -361,7 +357,6 @@ mod tests {
assert!(post_passed);
}
#[allow(clippy::indexing_slicing)]
let expected_buckets = |factor: u32, tokens_consumed: u32| {
let adjusted_configs = bucket_configs.map(|_, config| BucketConfig {
capacity: config.capacity.saturating_mul(factor),

View file

@ -107,8 +107,7 @@ pub fn markdown_check_for_blocked_urls(text: &str, blocklist: &RegexSet) -> Lemm
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {
use super::*;

View file

@ -134,8 +134,6 @@ pub fn add(markdown_parser: &mut MarkdownIt) {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
mod tests {
use crate::utils::markdown::spoiler_rule::add;

View file

@ -34,8 +34,7 @@ pub fn scrape_text_for_mentions(text: &str) -> Vec<MentionData> {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::indexing_slicing)]
mod test {
use crate::utils::mention::scrape_text_for_mentions;

View file

@ -61,8 +61,7 @@ pub(crate) fn slurs_vec_to_str(slurs: &[&str]) -> String {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod test {
use crate::utils::slurs::{remove_slurs, slur_check, slurs_vec_to_str};

View file

@ -351,7 +351,6 @@ pub fn build_url_str_without_scheme(url_str: &str) -> LemmyResult<String> {
}
#[cfg(test)]
#[allow(clippy::indexing_slicing)]
mod tests {
use crate::{

View file

@ -605,7 +605,6 @@ async fn build_update_instance_form(
}
#[cfg(test)]
#[allow(clippy::indexing_slicing)]
mod tests {
use crate::scheduled_tasks::build_update_instance_form;

View file

@ -97,8 +97,7 @@ where
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {
use super::*;