Skip to content

Commit

Permalink
Replace clippy allow annotation with expect (fixes #5012) (#5048)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nutomic authored Sep 24, 2024
1 parent 61a0248 commit f6a24e1
Show file tree
Hide file tree
Showing 60 changed files with 59 additions and 111 deletions.
2 changes: 0 additions & 2 deletions crates/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
9 changes: 4 additions & 5 deletions crates/api/src/site/registration_applications/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion crates/api/src/sitemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions crates/api_common/src/claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
3 changes: 1 addition & 2 deletions crates/api_common/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
3 changes: 1 addition & 2 deletions crates/api_common/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
2 changes: 0 additions & 2 deletions crates/api_crud/src/site/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions crates/api_crud/src/site/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 0 additions & 2 deletions crates/api_crud/src/site/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion crates/apub/src/activity_lists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ impl InCommunity for AnnouncableActivities {
}

#[cfg(test)]
#[allow(clippy::indexing_slicing)]
mod tests {

use crate::{
Expand Down
3 changes: 2 additions & 1 deletion crates/apub/src/api/user_settings_backup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion crates/apub/src/collections/community_moderators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl Collection for ApubCommunityModerators {
}

#[cfg(test)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::indexing_slicing)]
mod tests {

use super::*;
Expand Down
3 changes: 1 addition & 2 deletions crates/apub/src/http/community.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
2 changes: 1 addition & 1 deletion crates/db_perf/src/series.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions crates/db_schema/src/aggregates/comment_aggregates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ impl CommentAggregates {
}

#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {

use crate::{
Expand Down
3 changes: 1 addition & 2 deletions crates/db_schema/src/aggregates/community_aggregates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ impl CommunityAggregates {
}

#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {

use crate::{
Expand Down
3 changes: 1 addition & 2 deletions crates/db_schema/src/aggregates/person_aggregates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ impl PersonAggregates {
}

#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {

use crate::{
Expand Down
4 changes: 2 additions & 2 deletions crates/db_schema/src/aggregates/post_aggregates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ impl PostAggregates {
}

#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]

mod tests {

use crate::{
Expand Down
4 changes: 2 additions & 2 deletions crates/db_schema/src/aggregates/site_aggregates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ impl SiteAggregates {
}

#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]

mod tests {

use crate::{
Expand Down
3 changes: 1 addition & 2 deletions crates/db_schema/src/impls/activity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ impl ReceivedActivity {
}

#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {

use super::*;
Expand Down
4 changes: 2 additions & 2 deletions crates/db_schema/src/impls/actor_language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
2 changes: 0 additions & 2 deletions crates/db_schema/src/impls/captcha_answer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ impl CaptchaAnswer {
}

#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
mod tests {

use crate::{
Expand Down
3 changes: 1 addition & 2 deletions crates/db_schema/src/impls/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
1 change: 0 additions & 1 deletion crates/db_schema/src/impls/community.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,6 @@ impl ApubActor for Community {
}

#[cfg(test)]
#[allow(clippy::indexing_slicing)]
mod tests {
use crate::{
source::{
Expand Down
3 changes: 1 addition & 2 deletions crates/db_schema/src/impls/federation_allowlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ impl FederationAllowList {
}
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {

use crate::{
Expand Down
4 changes: 2 additions & 2 deletions crates/db_schema/src/impls/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
1 change: 0 additions & 1 deletion crates/db_schema/src/impls/local_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@ pub struct UserBackupLists {
}

#[cfg(test)]
#[allow(clippy::indexing_slicing)]
mod tests {
use crate::{
source::{
Expand Down
3 changes: 1 addition & 2 deletions crates/db_schema/src/impls/moderator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
2 changes: 0 additions & 2 deletions crates/db_schema/src/impls/password_reset_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ impl PasswordResetRequest {
}

#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
mod tests {

use crate::{
Expand Down
1 change: 0 additions & 1 deletion crates/db_schema/src/impls/person.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ impl PersonFollower {
}

#[cfg(test)]
#[allow(clippy::indexing_slicing)]
mod tests {

use crate::{
Expand Down
3 changes: 1 addition & 2 deletions crates/db_schema/src/impls/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,7 @@ impl PostHide {
}

#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {

use crate::{
Expand Down
3 changes: 1 addition & 2 deletions crates/db_schema/src/impls/post_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
3 changes: 1 addition & 2 deletions crates/db_schema/src/impls/private_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ impl PrivateMessage {
}

#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
mod tests {

use crate::{
Expand Down
1 change: 0 additions & 1 deletion crates/db_schema/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions crates/db_schema/src/newtypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion crates/db_schema/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,6 @@ impl<RF, LF> Queries<RF, LF> {
}

#[cfg(test)]
#[allow(clippy::indexing_slicing)]
mod tests {

use super::*;
Expand Down
4 changes: 2 additions & 2 deletions crates/db_views/src/comment_report_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
4 changes: 2 additions & 2 deletions crates/db_views/src/comment_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
Loading

0 comments on commit f6a24e1

Please sign in to comment.