From 5d874ae1d711c55a227dd67483a9be847abb959e Mon Sep 17 00:00:00 2001 From: anant Date: Mon, 23 Dec 2024 12:26:03 +0530 Subject: [PATCH] refactor: deepsource --- src/handlers/http/alerts/http_handlers.rs | 30 +++++++++-------------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/handlers/http/alerts/http_handlers.rs b/src/handlers/http/alerts/http_handlers.rs index 28afd3fb6..d40b95075 100644 --- a/src/handlers/http/alerts/http_handlers.rs +++ b/src/handlers/http/alerts/http_handlers.rs @@ -148,28 +148,22 @@ pub async fn update_state(req: HttpRequest, state: String) -> Result { - match new_state { - AlertState::Triggered => { - let msg = format!("Not allowed to manually go from Triggered to {new_state}"); - return Err(AlertError::InvalidStateChange(msg)); - } - _ => { - // update state on disk and in memory - ALERTS.update_state(alert_id, new_state, true).await?; - } + if new_state == AlertState::Triggered { + let msg = format!("Not allowed to manually go from Triggered to {new_state}"); + return Err(AlertError::InvalidStateChange(msg)); + } else { + // update state on disk and in memory + ALERTS.update_state(alert_id, new_state, true).await?; } } AlertState::Silenced => { // from here, the user can only go to Resolved - match new_state { - AlertState::Resolved => { - // update state on disk and in memory - ALERTS.update_state(alert_id, new_state, true).await?; - } - _ => { - let msg = format!("Not allowed to manually go from Silenced to {new_state}"); - return Err(AlertError::InvalidStateChange(msg)); - } + if new_state == AlertState::Resolved { + // update state on disk and in memory + ALERTS.update_state(alert_id, new_state, true).await?; + } else { + let msg = format!("Not allowed to manually go from Silenced to {new_state}"); + return Err(AlertError::InvalidStateChange(msg)); } } AlertState::Resolved => {