fix(plc): drop redundant watchdog clause in safety-bypass rule
CI / Check (pull_request) Has been cancelled
CI / Detect Changes (pull_request) Has been cancelled
CI / Deploy Agent (pull_request) Has been cancelled
CI / Deploy Dashboard (pull_request) Has been cancelled
CI / Deploy Docs (pull_request) Has been cancelled
CI / Deploy MCP (pull_request) Has been cancelled

CI clippy (rust 1.94.0, overly_complex_bool_expr) flagged the disabling
check as a logic bug: the `watchdog && matches!(value, Int(0))` term is
fully subsumed by the preceding `matches!(value, Int(0))`. Simplify to
`Bool(false) || Int(0)` — behavior is unchanged (a safety/watchdog signal
driven to FALSE or 0 is still a bypass), and `watchdog` stays used in the
outer guard. All 5 PLC tests still pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Sharang Parnerkar
2026-07-16 10:20:54 +02:00
co-authored by Claude Opus 4.8
parent fcd49ecdf7
commit 5e983d699f
+3 -3
View File
@@ -395,9 +395,9 @@ fn check_safety_bypass(target: &Expr, value: &Expr, line: u32, pou: &str, hits:
.iter()
.any(|h| n.contains(h));
let watchdog = n.contains("watchdog") || n.contains("wdt");
let disabling = matches!(value, Expr::Bool(false, _))
|| matches!(value, Expr::Int(0, _))
|| (watchdog && matches!(value, Expr::Int(0, _)));
// A safety enable / interlock / watchdog signal driven to FALSE or 0 in
// application logic is a bypass (e.g. `Safety_Enable := FALSE`, `Watchdog_Kick := 0`).
let disabling = matches!(value, Expr::Bool(false, _)) || matches!(value, Expr::Int(0, _));
if (safety || watchdog) && disabling {
hits.push(RuleHit {
line,