From 4bb3679e4139aea66d3c25de52d06143fbbb52c0 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 25 Oct 2026 21:28:59 -0400 Subject: [PATCH] Sonar: use PoisonError::into_inner, explicit test imports, [[ in import-cert - proof: pass PoisonError::into_inner instead of an identity closure (S1612). - layout tests: replace glob super::* imports with explicit names (S2208). - packaging/macos/import-cert.sh: use [[ for the status test (S7688). --- crates/layout/src/tests_linear.rs | 5 ++++- crates/layout/src/tests_nbsp.rs | 2 +- crates/layout/src/tests_table_contact.rs | 2 +- crates/proof/src/es/mod.rs | 10 +++++----- packaging/macos/import-cert.sh | 2 +- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/crates/layout/src/tests_linear.rs b/crates/layout/src/tests_linear.rs index e49409693..a90036b4e 100644 --- a/crates/layout/src/tests_linear.rs +++ b/crates/layout/src/tests_linear.rs @@ -6,7 +6,10 @@ //! whose walk is the document model's, is timed. use super::tests::{SCALE, cost_ratio}; -use super::*; +use super::{ + Block, CharProps, DocLayout, Document, HeaderSet, HeightRule, InlineObject, LayoutCache, LayoutOptions, ParaLayout, Paragraph, Path, Placed, + SectionProps, SectionStart, StoryRef, display, layout, para, work, +}; use wordcraft_doc::para::Run; use wordcraft_doc::{Pos, Table}; diff --git a/crates/layout/src/tests_nbsp.rs b/crates/layout/src/tests_nbsp.rs index b8dbc9aad..f9ee301b2 100644 --- a/crates/layout/src/tests_nbsp.rs +++ b/crates/layout/src/tests_nbsp.rs @@ -1,7 +1,7 @@ //! A no-break space is laid out as wide as an ordinary space, whatever the font's own U+00A0 //! glyph measures (Lucida Bright draws it twice as wide). -use super::*; +use super::{Document, LayoutCache, LayoutOptions, Placed, layout}; /// Inter with its U+00A0 glyph twice as wide as its space, under the family name "Wnbsp". /// Built from the bundled font so the test needs no installed font. diff --git a/crates/layout/src/tests_table_contact.rs b/crates/layout/src/tests_table_contact.rs index 8f3800c96..65a86f0f5 100644 --- a/crates/layout/src/tests_table_contact.rs +++ b/crates/layout/src/tests_table_contact.rs @@ -1,7 +1,7 @@ //! #3977: floating tables include a line's bottom edge; shapes keep a strict boundary. //! The expected distinction is cyril265's Word for Mac 16.114.1 observation in the issue. -use super::*; +use super::{Arc, Block, Document, LayoutCache, LayoutOptions, Placed, StoryRef, layout}; use wordcraft_doc::para::{Anchor, Float, InlineObject, ShapeKind, Wrap}; use wordcraft_doc::props::{HeightRule, LineSpacing, ParaProps, TableFloat}; use wordcraft_doc::{CharProps, Paragraph, Pos, Table}; diff --git a/crates/proof/src/es/mod.rs b/crates/proof/src/es/mod.rs index 94c6511ab..351a69b04 100644 --- a/crates/proof/src/es/mod.rs +++ b/crates/proof/src/es/mod.rs @@ -16,7 +16,7 @@ mod suggest; pub(crate) mod test_dict; pub mod voseo; -use std::sync::{Arc, RwLock}; +use std::sync::{Arc, PoisonError, RwLock}; use crate::ProofLang; use crate::affix::AffixDict; @@ -62,11 +62,11 @@ pub fn dictionary_name(lang: ProofLang) -> &'static str { /// see [`has_dictionary`]). pub fn dictionary(lang: ProofLang) -> Arc { let Some(slot) = DICTS.get(variety(lang).0) else { return Arc::new(AffixDict::default()) }; - if let Some(d) = slot.read().unwrap_or_else(|e| e.into_inner()).as_ref() { + if let Some(d) = slot.read().unwrap_or_else(PoisonError::into_inner).as_ref() { return d.clone(); } let loaded = Arc::new(load_installed(lang)); - let mut slot = slot.write().unwrap_or_else(|e| e.into_inner()); + let mut slot = slot.write().unwrap_or_else(PoisonError::into_inner); // Another thread (or an install) may have filled it meanwhile: that one wins. slot.get_or_insert(loaded).clone() } @@ -90,7 +90,7 @@ fn load_installed(lang: ProofLang) -> AffixDict { pub fn install_dictionary(lang: ProofLang, aff: &str, dic: &str) -> Result<(), String> { let d = AffixDict::from_hunspell(aff, dic, &[])?; if let Some(slot) = DICTS.get(variety(lang).0) { - *slot.write().unwrap_or_else(|e| e.into_inner()) = Some(Arc::new(d)); + *slot.write().unwrap_or_else(PoisonError::into_inner) = Some(Arc::new(d)); } Ok(()) } @@ -99,7 +99,7 @@ pub fn install_dictionary(lang: ProofLang, aff: &str, dic: &str) -> Result<(), S /// (after [`crate::hunspell::set_dictionary_dir`] or a dictionary was installed). pub fn reload_dictionary() { for slot in &DICTS { - *slot.write().unwrap_or_else(|e| e.into_inner()) = None; + *slot.write().unwrap_or_else(PoisonError::into_inner) = None; } } diff --git a/packaging/macos/import-cert.sh b/packaging/macos/import-cert.sh index a4e79ea8b..341d012f6 100755 --- a/packaging/macos/import-cert.sh +++ b/packaging/macos/import-cert.sh @@ -30,7 +30,7 @@ KEYCHAIN="$WORK/wordcraft-signing.keychain-db" cleanup() { local status=$? rm -f "$CERT" - if [ "$status" -ne 0 ]; then + if [[ "$status" -ne 0 ]]; then security delete-keychain "$KEYCHAIN" 2>/dev/null || true rm -rf "$WORK" fi