From e5400a237506c914ba92d6d9ba28b06a7a659886 Mon Sep 17 00:00:00 2001 From: TaprootFreak <142087526+TaprootFreak@users.noreply.github.com> Date: Sat, 23 May 2026 21:12:32 +0200 Subject: [PATCH] fix(scanner_ws_parse): flatten block arm so llvm-cov tracks line 37 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #87 merged with the nested `if let Some(block) { if let Some(hash) { if let Ok(h) = BlockHash::from_str(hash) { ... } } }` shape. The closing brace at line 37 (the path where `block.id` is a string but not a valid hex) reads as covered by the `parse_ws_frame_returns_empty_when_block_id_is_invalid_hex` test in local `cargo test`, but llvm-cov's region tracking reports the closing-brace region as untaken — the Coverage Gate flags `server/src/scanner_ws_parse.rs:37` as the only uncovered line. Flatten the block arm to a single Option chain (`block.get("id").and_then(...).and_then(...).map(...).unwrap_or_default()`). Behavior is identical across every input shape the existing tests cover; LLVM's region tracking collapses cleanly because the closing brace no longer exists as a distinct sub-region. Affects PR #18 (Release: develop -> main) and any open PR based on develop (e.g. #90). --- server/src/scanner_ws_parse.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server/src/scanner_ws_parse.rs b/server/src/scanner_ws_parse.rs index c6c8bd17..56597a5b 100644 --- a/server/src/scanner_ws_parse.rs +++ b/server/src/scanner_ws_parse.rs @@ -30,12 +30,12 @@ pub fn parse_ws_frame(text: &str) -> Vec { }; if let Some(block) = value.get("block") { - if let Some(hash) = block.get("id").and_then(|v| v.as_str()) { - if let Ok(h) = BlockHash::from_str(hash) { - return vec![h]; - } - } - return Vec::new(); + return block + .get("id") + .and_then(|v| v.as_str()) + .and_then(|s| BlockHash::from_str(s).ok()) + .map(|h| vec![h]) + .unwrap_or_default(); } if let Some(blocks) = value.get("blocks").and_then(|v| v.as_array()) {