Skip to content

Commit

Permalink
Replace clippy allow annotation with expect (fixes #5012)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nutomic committed Sep 24, 2024
1 parent 9eee61d commit 322ccfe
Show file tree
Hide file tree
Showing 60 changed files with 97 additions and 110 deletions.
4 changes: 2 additions & 2 deletions crates/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ pub async fn local_user_view_from_jwt(
}

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

use super::*;
Expand Down
8 changes: 4 additions & 4 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,8 +138,8 @@ async fn get_application_statuses(
Ok((application_count, unread_applications, all_applications))
}

#[allow(clippy::indexing_slicing)]
#[allow(clippy::unwrap_used)]
#[expect(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
#[tokio::test]
#[serial]
async fn test_application_approval() -> LemmyResult<()> {
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
4 changes: 2 additions & 2 deletions crates/api_common/src/claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ impl Claims {
}

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

use crate::{claims::Claims, context::LemmyContext};
Expand Down
4 changes: 2 additions & 2 deletions crates/api_common/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,8 @@ pub async fn replace_image(
}

#[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/api_common/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1067,8 +1067,8 @@ fn build_proxied_image_url(
}

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

use super::*;
Expand Down
4 changes: 2 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,8 @@ fn validate_create_payload(local_site: &LocalSite, create_site: &CreateSite) ->
}

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

use crate::site::create::validate_create_payload;
Expand Down
4 changes: 2 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,8 @@ fn not_zero(val: Option<i32>) -> Option<i32> {
}

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

use crate::site::{application_question_check, not_zero, site_default_post_listing_type_check};
Expand Down
4 changes: 2 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,8 @@ fn validate_update_payload(local_site: &LocalSite, edit_site: &EditSite) -> Lemm
}

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

use crate::site::update::validate_update_payload;
Expand Down
2 changes: 1 addition & 1 deletion crates/apub/src/activity_lists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl InCommunity for AnnouncableActivities {
}

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

use crate::{
Expand Down
2 changes: 1 addition & 1 deletion crates/apub/src/api/user_settings_backup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ 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
4 changes: 2 additions & 2 deletions crates/apub/src/http/community.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ pub(crate) async fn get_apub_community_featured(
}

#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
#[expect(clippy::indexing_slicing)]
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
4 changes: 2 additions & 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,8 @@ impl CommentAggregates {
}

#[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_schema/src/aggregates/community_aggregates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ impl CommunityAggregates {
}

#[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_schema/src/aggregates/person_aggregates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ impl PersonAggregates {
}

#[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_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)]
#[expect(clippy::indexing_slicing)]
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)]
#[expect(clippy::indexing_slicing)]
mod tests {

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

#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::unwrap_used)]
#[expect(clippy::indexing_slicing)]
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
4 changes: 2 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,8 @@ impl CaptchaAnswer {
}

#[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_schema/src/impls/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ impl Saveable for CommentSaved {
}

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

use crate::{
Expand Down
2 changes: 1 addition & 1 deletion crates/db_schema/src/impls/community.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ impl ApubActor for Community {
}

#[cfg(test)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::indexing_slicing)]
mod tests {
use crate::{
source::{
Expand Down
4 changes: 2 additions & 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,8 @@ impl FederationAllowList {
}
}
#[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_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
2 changes: 1 addition & 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,7 @@ pub struct UserBackupLists {
}

#[cfg(test)]
#[allow(clippy::indexing_slicing)]
#[expect(clippy::indexing_slicing)]
mod tests {
use crate::{
source::{
Expand Down
4 changes: 2 additions & 2 deletions crates/db_schema/src/impls/moderator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ impl Crud for AdminPurgeComment {
}

#[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_schema/src/impls/password_reset_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ impl PasswordResetRequest {
}

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

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

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

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

#[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_schema/src/impls/post_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ impl Reportable for PostReport {
}

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

use super::*;
Expand Down
4 changes: 2 additions & 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,8 @@ impl PrivateMessage {
}

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

use crate::{
Expand Down
2 changes: 1 addition & 1 deletion crates/db_schema/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub mod newtypes;
pub mod sensitive;
#[cfg(feature = "full")]
#[rustfmt::skip]
#[allow(clippy::wildcard_imports)]
#[expect(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
2 changes: 1 addition & 1 deletion crates/db_schema/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ impl<RF, LF> Queries<RF, LF> {
}

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

use super::*;
Expand Down
Loading

0 comments on commit 322ccfe

Please sign in to comment.