From cd6661c3ff0645df96264622a835ddaf48f25b03 Mon Sep 17 00:00:00 2001 From: David Hagerty Date: Thu, 12 Feb 2026 21:58:40 -0500 Subject: [PATCH] fix(security): collapse nested if statements using let-chains Fix 3 clippy warnings for collapsible_if statements in check_path and check_command methods. Use let-chains (stable in edition 2024, Rust 1.85.0+) instead of nested if let/if blocks for more idiomatic code. - Lines 82-89: check_path denied patterns loop - Lines 94-99: check_path allowed patterns loop - Lines 107-111: check_command allowed commands loop Co-Authored-By: Claude Opus 4.6 --- src/security/scope.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/security/scope.rs b/src/security/scope.rs index 8bf528a..be596db 100644 --- a/src/security/scope.rs +++ b/src/security/scope.rs @@ -79,22 +79,22 @@ impl SecurityScope { // Check denied patterns first (deny takes precedence) for pattern_str in &self.denied_paths { - if let Ok(pattern) = Pattern::new(pattern_str) { - if pattern.matches_path_with(path_ref, opts) { - return ScopeCheck::Denied(format!( - "path matches denied pattern: {}", - pattern_str - )); - } + if let Ok(pattern) = Pattern::new(pattern_str) + && pattern.matches_path_with(path_ref, opts) + { + return ScopeCheck::Denied(format!( + "path matches denied pattern: {}", + pattern_str + )); } } // Check allowed patterns for pattern_str in &self.allowed_paths { - if let Ok(pattern) = Pattern::new(pattern_str) { - if pattern.matches_path_with(path_ref, opts) { - return ScopeCheck::Allowed; - } + if let Ok(pattern) = Pattern::new(pattern_str) + && pattern.matches_path_with(path_ref, opts) + { + return ScopeCheck::Allowed; } } @@ -104,10 +104,10 @@ impl SecurityScope { /// Check whether a shell command is permitted. pub fn check_command(&self, command: &str) -> ScopeCheck { for pattern_str in &self.allowed_commands { - if let Ok(pattern) = Pattern::new(pattern_str) { - if pattern.matches(command) { - return ScopeCheck::Allowed; - } + if let Ok(pattern) = Pattern::new(pattern_str) + && pattern.matches(command) + { + return ScopeCheck::Allowed; } } -- 2.51.2