fix: resolve all clippy warnings for CI (async_fn_in_trait, collapsible_if, type_complexity, dead_code)

- Allow async_fn_in_trait lint crate-wide (internal project, 413 warnings)
- Add integration_tests feature to Cargo.toml to fix unexpected cfg warnings
- Collapse nested if statements into single conditions (13 locations)
- Add type_complexity allows on pg repository functions (12 locations)
- Fix dead code warnings in test modules with allow attributes
- Fix E0599 by gating new_stub() for integration_tests feature
- Add result_unit_err and result_large_err allows where appropriate
- Apply rustfmt formatting

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
zjean
2026-03-04 21:40:38 +01:00
parent a7de63d80f
commit 45c60faeb5
11 changed files with 77 additions and 52 deletions
@@ -1041,10 +1041,15 @@ impl BatchOperationService {
#[cfg(integration_tests)]
mod tests {
#[allow(unused_imports)]
use super::*;
#[allow(unused_imports)]
use crate::infrastructure::repositories::pg::file_blob_read_repository::FileBlobReadRepository;
#[allow(unused_imports)]
use crate::infrastructure::repositories::pg::file_blob_write_repository::FileBlobWriteRepository;
#[allow(unused_imports)]
use crate::infrastructure::repositories::pg::folder_db_repository::FolderDbRepository;
#[allow(unused_imports)]
use std::sync::Arc;
#[tokio::test]
@@ -131,17 +131,20 @@ impl FileReadPort for MockFileReadPort {
}
/// Minimal mock write port — only `move_file` and `rename_file` need real logic.
#[allow(dead_code)]
struct MockFileWritePort {
files: Mutex<HashMap<String, File>>,
}
impl MockFileWritePort {
#[allow(dead_code)]
fn new() -> Self {
Self {
files: Mutex::new(HashMap::new()),
}
}
#[allow(dead_code)]
fn insert(&self, id: &str, name: &str) {
let file = File::new(
id.to_string(),
+3 -1
View File
@@ -430,9 +430,11 @@ impl ShareUseCase for ShareService {
}
}
#[cfg(integration_tests)]
#[cfg(feature = "integration_tests")]
#[allow(dead_code)]
mod tests {
use super::*;
#[allow(unused_imports)]
use crate::application::dtos::share_dto::SharePermissionsDto;
use crate::application::ports::auth_ports::PasswordHasherPort;
use crate::application::ports::share_ports::ShareStoragePort;
+36 -38
View File
@@ -197,14 +197,14 @@ where
.file_write_port
.restore_from_trash(&file_id, &original_path)
.await;
if let Err(e) = result {
if !format!("{}", e).contains("not found") {
return Err(DomainError::new(
ErrorKind::InternalError,
"File",
format!("Error restoring file {} from trash: {}", file_id, e),
));
}
if let Err(e) = result
&& !format!("{}", e).contains("not found")
{
return Err(DomainError::new(
ErrorKind::InternalError,
"File",
format!("Error restoring file {} from trash: {}", file_id, e),
));
}
}
TrashedItemType::Folder => {
@@ -214,17 +214,14 @@ where
.folder_storage_port
.restore_from_trash(&folder_id, &original_path)
.await;
if let Err(e) = result {
if !format!("{}", e).contains("not found") {
return Err(DomainError::new(
ErrorKind::InternalError,
"Folder",
format!(
"Error restoring folder {} from trash: {}",
folder_id, e
),
));
}
if let Err(e) = result
&& !format!("{}", e).contains("not found")
{
return Err(DomainError::new(
ErrorKind::InternalError,
"Folder",
format!("Error restoring folder {} from trash: {}", folder_id, e),
));
}
}
}
@@ -260,14 +257,14 @@ where
TrashedItemType::File => {
let file_id = item.original_id().to_string();
let result = self.file_write_port.delete_file_permanently(&file_id).await;
if let Err(e) = result {
if !format!("{}", e).contains("not found") {
return Err(DomainError::new(
ErrorKind::InternalError,
"File",
format!("Error deleting file {} permanently: {}", file_id, e),
));
}
if let Err(e) = result
&& !format!("{}", e).contains("not found")
{
return Err(DomainError::new(
ErrorKind::InternalError,
"File",
format!("Error deleting file {} permanently: {}", file_id, e),
));
}
}
TrashedItemType::Folder => {
@@ -276,17 +273,14 @@ where
.folder_storage_port
.delete_folder_permanently(&folder_id)
.await;
if let Err(e) = result {
if !format!("{}", e).contains("not found") {
return Err(DomainError::new(
ErrorKind::InternalError,
"Folder",
format!(
"Error deleting folder {} permanently: {}",
folder_id, e
),
));
}
if let Err(e) = result
&& !format!("{}", e).contains("not found")
{
return Err(DomainError::new(
ErrorKind::InternalError,
"Folder",
format!("Error deleting folder {} permanently: {}", folder_id, e),
));
}
}
}
@@ -804,9 +798,13 @@ impl FolderRepository for MockFolderRepository {
#[cfg(integration_tests)]
mod tests {
#[allow(unused_imports)]
use super::*;
#[allow(unused_imports)]
use crate::application::ports::trash_ports::TrashUseCase;
#[allow(unused_imports)]
use crate::infrastructure::repositories::pg::file_blob_read_repository::FileBlobReadRepository;
#[allow(unused_imports)]
use crate::infrastructure::repositories::pg::file_blob_write_repository::FileBlobWriteRepository;
#[tokio::test]