fix(tests): suppress clippy expect warnings in enhance function

fix(timer): improve task removal logic in add_task method
refactor(notification): drop binding after emitting event
chore(Cargo): add lints section to Cargo.toml
This commit is contained in:
Tunglies
2025-11-20 14:59:49 +08:00
parent 4c8673fcb2
commit b3dc48d07e
5 changed files with 7 additions and 5 deletions

View File

@@ -123,3 +123,6 @@ tauri-plugin-updater = "2.9.0"
[dev-dependencies]
criterion = { workspace = true }
[lints]
workspace = true

View File

@@ -4,7 +4,7 @@ use super::CmdResult;
use crate::core::{CoreManager, handle, manager::RunningMode};
use clash_verge_logging::{Type, logging};
use parking_lot::RwLock;
use tauri::Manager;
use tauri::Manager as _;
use tauri_plugin_clash_verge_sysinfo::Platform;
use tauri_plugin_clipboard_manager::ClipboardExt as _;

View File

@@ -102,8 +102,6 @@ impl NotificationSystem {
}
}
// Clippy 似乎对 parking lot 的 RwLock 有误报,这里禁用相关警告
#[allow(clippy::significant_drop_tightening)]
fn process_event(handle: &super::handle::Handle, event: FrontendEvent) {
let binding = handle.notification_system.read();
let system = match binding.as_ref() {
@@ -117,6 +115,7 @@ impl NotificationSystem {
if let Some(window) = super::handle::Handle::get_window() {
system.emit_to_window(&window, event);
drop(binding);
thread::sleep(timing::EVENT_EMIT_DELAY);
}
}

View File

@@ -253,12 +253,11 @@ impl Timer {
// Now perform async operations without holding locks
let delay_timer = self.delay_timer.write();
let mut timer_map = self.timer_map.write();
for (uid, tid, interval) in operations_to_add {
if let Err(e) = self.add_task(&delay_timer, uid.clone(), tid, interval) {
logging_error!(Type::Timer, "Failed to add task for uid {}: {}", uid, e);
// Rollback on failure - remove from timer_map
timer_map.remove(&uid);
self.timer_map.write().remove(&uid);
} else {
logging!(debug, Type::Timer, "Added task {} for uid {}", tid, uid);
}

View File

@@ -692,6 +692,7 @@ pub async fn enhance() -> (Mapping, Vec<String>, HashMap<String, ResultLog>) {
(config, exists_keys, result_map)
}
#[allow(clippy::expect_used)]
#[cfg(test)]
mod tests {
use super::cleanup_proxy_groups;