diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 801c60b2..2c0dcfbb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,29 +28,29 @@ jobs: submodules: true - run: rustup update && rustup default 1.70.0 && rustup component add clippy - uses: Swatinem/rust-cache@v2 - - run: cargo clippy -- -D warnings -D clippy::all + - run: cargo clippy --all-targets -- -D warnings -D clippy::all working-directory: ./lib/oxsdatatypes - - run: cargo clippy -- -D warnings -D clippy::all + - run: cargo clippy --all-targets -- -D warnings -D clippy::all working-directory: ./lib/oxrdf - - run: cargo clippy -- -D warnings -D clippy::all + - run: cargo clippy --all-targets -- -D warnings -D clippy::all working-directory: ./lib/oxrdfxml - - run: cargo clippy -- -D warnings -D clippy::all + - run: cargo clippy --all-targets -- -D warnings -D clippy::all working-directory: ./lib/oxttl - - run: cargo clippy -- -D warnings -D clippy::all + - run: cargo clippy --all-targets -- -D warnings -D clippy::all working-directory: ./lib/oxrdfio - - run: cargo clippy -- -D warnings -D clippy::all + - run: cargo clippy --all-targets -- -D warnings -D clippy::all working-directory: ./lib/sparesults - - run: cargo clippy -- -D warnings -D clippy::all + - run: cargo clippy --all-targets -- -D warnings -D clippy::all working-directory: ./lib/spargebra - - run: cargo clippy -- -D warnings -D clippy::all + - run: cargo clippy --all-targets -- -D warnings -D clippy::all working-directory: ./lib/sparopt - - run: cargo clippy -- -D warnings -D clippy::all + - run: cargo clippy --all-targets -- -D warnings -D clippy::all working-directory: ./lib - - run: cargo clippy -- -D warnings -D clippy::all + - run: cargo clippy --all-targets -- -D warnings -D clippy::all working-directory: ./python - - run: cargo clippy -- -D warnings -D clippy::all + - run: cargo clippy --all-targets -- -D warnings -D clippy::all working-directory: ./cli - - run: cargo clippy -- -D warnings -D clippy::all + - run: cargo clippy --all-targets -- -D warnings -D clippy::all working-directory: ./testsuite clippy_wasm_js: diff --git a/cli/src/main.rs b/cli/src/main.rs index 07c84592..6b2abba4 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -1818,6 +1818,8 @@ fn systemd_notify_ready() -> io::Result<()> { #[cfg(test)] mod tests { + #![allow(clippy::panic_in_result_fn)] + use super::*; use anyhow::Result; use assert_cmd::Command; diff --git a/lib/oxrdf/src/blank_node.rs b/lib/oxrdf/src/blank_node.rs index bfd27231..937b1efb 100644 --- a/lib/oxrdf/src/blank_node.rs +++ b/lib/oxrdf/src/blank_node.rs @@ -363,6 +363,8 @@ impl Error for BlankNodeIdParseError {} #[cfg(test)] mod tests { + #![allow(clippy::panic_in_result_fn)] + use super::*; #[test] @@ -379,13 +381,13 @@ mod tests { #[test] fn new_validation() { - assert!(BlankNode::new("").is_err()); - assert!(BlankNode::new("a").is_ok()); - assert!(BlankNode::new("-").is_err()); - assert!(BlankNode::new("a-").is_ok()); - assert!(BlankNode::new(".").is_err()); - assert!(BlankNode::new("a.").is_err()); - assert!(BlankNode::new("a.a").is_ok()); + BlankNode::new("").unwrap_err(); + BlankNode::new("a").unwrap(); + BlankNode::new("-").unwrap_err(); + BlankNode::new("a-").unwrap(); + BlankNode::new(".").unwrap_err(); + BlankNode::new("a.").unwrap_err(); + BlankNode::new("a.a").unwrap(); } #[test] diff --git a/lib/oxrdf/src/dataset.rs b/lib/oxrdf/src/dataset.rs index 017825b0..eb655dea 100644 --- a/lib/oxrdf/src/dataset.rs +++ b/lib/oxrdf/src/dataset.rs @@ -1567,35 +1567,40 @@ type QuadsPerBlankNode = HashMap< )>, >; -#[test] -fn test_canon() { - let mut dataset = Dataset::new(); - dataset.insert(QuadRef::new( - BlankNode::default().as_ref(), - NamedNodeRef::new_unchecked("http://ex"), - BlankNode::default().as_ref(), - GraphNameRef::DefaultGraph, - )); - dataset.insert(QuadRef::new( - BlankNode::default().as_ref(), - NamedNodeRef::new_unchecked("http://ex"), - BlankNode::default().as_ref(), - GraphNameRef::DefaultGraph, - )); - dataset.canonicalize(); - let mut dataset2 = Dataset::new(); - dataset2.insert(QuadRef::new( - BlankNode::default().as_ref(), - NamedNodeRef::new_unchecked("http://ex"), - BlankNode::default().as_ref(), - GraphNameRef::DefaultGraph, - )); - dataset2.insert(QuadRef::new( - BlankNode::default().as_ref(), - NamedNodeRef::new_unchecked("http://ex"), - BlankNode::default().as_ref(), - GraphNameRef::DefaultGraph, - )); - dataset2.canonicalize(); - assert_eq!(dataset, dataset2); +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_canon() { + let mut dataset = Dataset::new(); + dataset.insert(QuadRef::new( + BlankNode::default().as_ref(), + NamedNodeRef::new_unchecked("http://ex"), + BlankNode::default().as_ref(), + GraphNameRef::DefaultGraph, + )); + dataset.insert(QuadRef::new( + BlankNode::default().as_ref(), + NamedNodeRef::new_unchecked("http://ex"), + BlankNode::default().as_ref(), + GraphNameRef::DefaultGraph, + )); + dataset.canonicalize(); + let mut dataset2 = Dataset::new(); + dataset2.insert(QuadRef::new( + BlankNode::default().as_ref(), + NamedNodeRef::new_unchecked("http://ex"), + BlankNode::default().as_ref(), + GraphNameRef::DefaultGraph, + )); + dataset2.insert(QuadRef::new( + BlankNode::default().as_ref(), + NamedNodeRef::new_unchecked("http://ex"), + BlankNode::default().as_ref(), + GraphNameRef::DefaultGraph, + )); + dataset2.canonicalize(); + assert_eq!(dataset, dataset2); + } } diff --git a/lib/oxrdf/src/literal.rs b/lib/oxrdf/src/literal.rs index 91f8455f..809f10e4 100644 --- a/lib/oxrdf/src/literal.rs +++ b/lib/oxrdf/src/literal.rs @@ -636,6 +636,8 @@ pub fn print_quoted_str(string: &str, f: &mut impl Write) -> fmt::Result { #[cfg(test)] mod tests { + #![allow(clippy::panic_in_result_fn)] + use super::*; #[test] diff --git a/lib/oxrdfxml/src/serializer.rs b/lib/oxrdfxml/src/serializer.rs index 01e5b4b4..8a025390 100644 --- a/lib/oxrdfxml/src/serializer.rs +++ b/lib/oxrdfxml/src/serializer.rs @@ -338,16 +338,21 @@ fn split_iri(iri: &str) -> (&str, &str) { } } -#[test] -fn test_split_iri() { - assert_eq!( - split_iri("http://schema.org/Person"), - ("http://schema.org/", "Person") - ); - assert_eq!(split_iri("http://schema.org/"), ("http://schema.org/", "")); - assert_eq!( - split_iri("http://schema.org#foo"), - ("http://schema.org#", "foo") - ); - assert_eq!(split_iri("urn:isbn:foo"), ("urn:isbn:", "foo")); +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_split_iri() { + assert_eq!( + split_iri("http://schema.org/Person"), + ("http://schema.org/", "Person") + ); + assert_eq!(split_iri("http://schema.org/"), ("http://schema.org/", "")); + assert_eq!( + split_iri("http://schema.org#foo"), + ("http://schema.org#", "foo") + ); + assert_eq!(split_iri("urn:isbn:foo"), ("urn:isbn:", "foo")); + } } diff --git a/lib/oxsdatatypes/src/boolean.rs b/lib/oxsdatatypes/src/boolean.rs index de29debc..688af076 100644 --- a/lib/oxsdatatypes/src/boolean.rs +++ b/lib/oxsdatatypes/src/boolean.rs @@ -85,6 +85,8 @@ impl fmt::Display for Boolean { #[cfg(test)] mod tests { + #![allow(clippy::panic_in_result_fn)] + use super::*; #[test] diff --git a/lib/oxsdatatypes/src/date_time.rs b/lib/oxsdatatypes/src/date_time.rs index 6c525794..f7c80431 100644 --- a/lib/oxsdatatypes/src/date_time.rs +++ b/lib/oxsdatatypes/src/date_time.rs @@ -2452,6 +2452,8 @@ impl Error for InvalidTimezoneError {} #[cfg(test)] mod tests { + #![allow(clippy::panic_in_result_fn)] + use super::*; #[test] @@ -2613,9 +2615,9 @@ mod tests { assert_eq!(GMonth::from_str("--01+01:00")?.to_string(), "--01+01:00"); assert_eq!(GMonth::from_str("--01")?.to_string(), "--01"); - assert!(GYear::from_str("02020").is_err()); - assert!(GYear::from_str("+2020").is_err()); - assert!(GYear::from_str("33").is_err()); + GYear::from_str("02020").unwrap_err(); + GYear::from_str("+2020").unwrap_err(); + GYear::from_str("33").unwrap_err(); assert_eq!(Time::from_str("00:00:00+14:00")?, Time::MIN); assert_eq!(Time::from_str("24:00:00-14:00")?, Time::MAX); @@ -3155,10 +3157,9 @@ mod tests { } #[test] - fn g_year_month_from_date() -> Result<(), ParseDateTimeError> { + fn g_year_month_from_date() { assert_eq!(GYearMonth::from(Date::MIN), GYearMonth::MIN); assert_eq!(GYearMonth::from(Date::MAX), GYearMonth::MAX); - Ok(()) } #[test] diff --git a/lib/oxsdatatypes/src/decimal.rs b/lib/oxsdatatypes/src/decimal.rs index fca06e5a..bb2090fd 100644 --- a/lib/oxsdatatypes/src/decimal.rs +++ b/lib/oxsdatatypes/src/decimal.rs @@ -674,6 +674,8 @@ impl Error for TooLargeForDecimalError {} #[cfg(test)] mod tests { + #![allow(clippy::panic_in_result_fn)] + use super::*; #[test] @@ -688,14 +690,14 @@ mod tests { #[test] fn from_str() -> Result<(), ParseDecimalError> { - assert!(Decimal::from_str("").is_err()); - assert!(Decimal::from_str("+").is_err()); - assert!(Decimal::from_str("-").is_err()); - assert!(Decimal::from_str(".").is_err()); - assert!(Decimal::from_str("+.").is_err()); - assert!(Decimal::from_str("-.").is_err()); - assert!(Decimal::from_str("a").is_err()); - assert!(Decimal::from_str(".a").is_err()); + Decimal::from_str("").unwrap_err(); + Decimal::from_str("+").unwrap_err(); + Decimal::from_str("-").unwrap_err(); + Decimal::from_str(".").unwrap_err(); + Decimal::from_str("+.").unwrap_err(); + Decimal::from_str("-.").unwrap_err(); + Decimal::from_str("a").unwrap_err(); + Decimal::from_str(".a").unwrap_err(); assert_eq!(Decimal::from_str("210")?.to_string(), "210"); assert_eq!(Decimal::from_str("1000")?.to_string(), "1000"); assert_eq!(Decimal::from_str("-1.23")?.to_string(), "-1.23"); @@ -713,8 +715,8 @@ mod tests { assert_eq!(Decimal::from_str("-0")?.to_string(), "0"); assert_eq!(Decimal::from_str(&Decimal::MAX.to_string())?, Decimal::MAX); assert_eq!(Decimal::from_str(&Decimal::MIN.to_string())?, Decimal::MIN); - assert!(Decimal::from_str("0.0000000000000000001").is_err()); - assert!(Decimal::from_str("1000000000000000000000").is_err()); + Decimal::from_str("0.0000000000000000001").unwrap_err(); + Decimal::from_str("1000000000000000000000").unwrap_err(); assert_eq!( Decimal::from_str("0.100000000000000000000000000").unwrap(), Decimal::from_str("0.1").unwrap() @@ -1019,11 +1021,11 @@ mod tests { Decimal::try_from(Float::from(-123.5)).ok(), Some(Decimal::from_str("-123.5")?) ); - assert!(Decimal::try_from(Float::from(f32::NAN)).is_err()); - assert!(Decimal::try_from(Float::from(f32::INFINITY)).is_err()); - assert!(Decimal::try_from(Float::from(f32::NEG_INFINITY)).is_err()); - assert!(Decimal::try_from(Float::from(f32::MIN)).is_err()); - assert!(Decimal::try_from(Float::from(f32::MAX)).is_err()); + Decimal::try_from(Float::from(f32::NAN)).unwrap_err(); + Decimal::try_from(Float::from(f32::INFINITY)).unwrap_err(); + Decimal::try_from(Float::from(f32::NEG_INFINITY)).unwrap_err(); + Decimal::try_from(Float::from(f32::MIN)).unwrap_err(); + Decimal::try_from(Float::from(f32::MAX)).unwrap_err(); assert!( Decimal::try_from(Float::from(1_672_507_300_000.)) .unwrap() @@ -1059,11 +1061,11 @@ mod tests { .unwrap() < Decimal::from(1) ); - assert!(Decimal::try_from(Double::from(f64::NAN)).is_err()); - assert!(Decimal::try_from(Double::from(f64::INFINITY)).is_err()); - assert!(Decimal::try_from(Double::from(f64::NEG_INFINITY)).is_err()); - assert!(Decimal::try_from(Double::from(f64::MIN)).is_err()); - assert!(Decimal::try_from(Double::from(f64::MAX)).is_err()); + Decimal::try_from(Double::from(f64::NAN)).unwrap_err(); + Decimal::try_from(Double::from(f64::INFINITY)).unwrap_err(); + Decimal::try_from(Double::from(f64::NEG_INFINITY)).unwrap_err(); + Decimal::try_from(Double::from(f64::MIN)).unwrap_err(); + Decimal::try_from(Double::from(f64::MAX)).unwrap_err(); Ok(()) } diff --git a/lib/oxsdatatypes/src/double.rs b/lib/oxsdatatypes/src/double.rs index bc040738..5ce5790d 100644 --- a/lib/oxsdatatypes/src/double.rs +++ b/lib/oxsdatatypes/src/double.rs @@ -261,6 +261,8 @@ impl Div for Double { #[cfg(test)] mod tests { + #![allow(clippy::panic_in_result_fn)] + use super::*; #[test] diff --git a/lib/oxsdatatypes/src/duration.rs b/lib/oxsdatatypes/src/duration.rs index f8162272..1cf33ffb 100644 --- a/lib/oxsdatatypes/src/duration.rs +++ b/lib/oxsdatatypes/src/duration.rs @@ -996,6 +996,8 @@ impl From for ParseDurationError { #[cfg(test)] mod tests { + #![allow(clippy::panic_in_result_fn)] + use super::*; #[test] diff --git a/lib/oxsdatatypes/src/float.rs b/lib/oxsdatatypes/src/float.rs index 996a6401..e8784b84 100644 --- a/lib/oxsdatatypes/src/float.rs +++ b/lib/oxsdatatypes/src/float.rs @@ -251,6 +251,8 @@ impl Div for Float { #[cfg(test)] mod tests { + #![allow(clippy::panic_in_result_fn)] + use super::*; #[test] diff --git a/lib/oxsdatatypes/src/integer.rs b/lib/oxsdatatypes/src/integer.rs index 352e521a..376deea6 100644 --- a/lib/oxsdatatypes/src/integer.rs +++ b/lib/oxsdatatypes/src/integer.rs @@ -278,6 +278,8 @@ impl Error for TooLargeForIntegerError {} #[cfg(test)] mod tests { + #![allow(clippy::panic_in_result_fn)] + use super::*; #[test] @@ -286,7 +288,7 @@ mod tests { assert_eq!(Integer::from_str("-0")?.to_string(), "0"); assert_eq!(Integer::from_str("123")?.to_string(), "123"); assert_eq!(Integer::from_str("-123")?.to_string(), "-123"); - assert!(Integer::from_str("123456789123456789123456789123456789123456789").is_err()); + Integer::from_str("123456789123456789123456789123456789123456789").unwrap_err(); Ok(()) } @@ -304,11 +306,11 @@ mod tests { Integer::try_from(Float::from(-123.1)).ok(), Some(Integer::from_str("-123")?) ); - assert!(Integer::try_from(Float::from(f32::NAN)).is_err()); - assert!(Integer::try_from(Float::from(f32::INFINITY)).is_err()); - assert!(Integer::try_from(Float::from(f32::NEG_INFINITY)).is_err()); - assert!(Integer::try_from(Float::from(f32::MIN)).is_err()); - assert!(Integer::try_from(Float::from(f32::MAX)).is_err()); + Integer::try_from(Float::from(f32::NAN)).unwrap_err(); + Integer::try_from(Float::from(f32::INFINITY)).unwrap_err(); + Integer::try_from(Float::from(f32::NEG_INFINITY)).unwrap_err(); + Integer::try_from(Float::from(f32::MIN)).unwrap_err(); + Integer::try_from(Float::from(f32::MAX)).unwrap_err(); assert!( Integer::try_from(Float::from(1_672_507_300_000.)) .unwrap() @@ -344,11 +346,11 @@ mod tests { .unwrap() < Integer::from(10) ); - assert!(Integer::try_from(Double::from(f64::NAN)).is_err()); - assert!(Integer::try_from(Double::from(f64::INFINITY)).is_err()); - assert!(Integer::try_from(Double::from(f64::NEG_INFINITY)).is_err()); - assert!(Integer::try_from(Double::from(f64::MIN)).is_err()); - assert!(Integer::try_from(Double::from(f64::MAX)).is_err()); + Integer::try_from(Double::from(f64::NAN)).unwrap_err(); + Integer::try_from(Double::from(f64::INFINITY)).unwrap_err(); + Integer::try_from(Double::from(f64::NEG_INFINITY)).unwrap_err(); + Integer::try_from(Double::from(f64::MIN)).unwrap_err(); + Integer::try_from(Double::from(f64::MAX)).unwrap_err(); Ok(()) } @@ -362,8 +364,8 @@ mod tests { Integer::try_from(Decimal::from_str("-123.1").unwrap()).ok(), Some(Integer::from_str("-123")?) ); - assert!(Integer::try_from(Decimal::MIN).is_err()); - assert!(Integer::try_from(Decimal::MAX).is_err()); + Integer::try_from(Decimal::MIN).unwrap_err(); + Integer::try_from(Decimal::MAX).unwrap_err(); Ok(()) } diff --git a/lib/oxttl/src/trig.rs b/lib/oxttl/src/trig.rs index 1b5e04a3..748e3d6a 100644 --- a/lib/oxttl/src/trig.rs +++ b/lib/oxttl/src/trig.rs @@ -860,6 +860,8 @@ fn is_turtle_double(value: &str) -> bool { #[cfg(test)] mod tests { + #![allow(clippy::panic_in_result_fn)] + use super::*; use oxrdf::vocab::xsd; use oxrdf::{BlankNodeRef, GraphNameRef, LiteralRef, NamedNodeRef}; diff --git a/lib/oxttl/src/turtle.rs b/lib/oxttl/src/turtle.rs index 7106758d..2272e9f8 100644 --- a/lib/oxttl/src/turtle.rs +++ b/lib/oxttl/src/turtle.rs @@ -666,6 +666,8 @@ impl LowLevelTurtleWriter { #[cfg(test)] mod tests { + #![allow(clippy::panic_in_result_fn)] + use super::*; use oxrdf::{BlankNodeRef, LiteralRef, NamedNodeRef}; diff --git a/lib/sparesults/src/csv.rs b/lib/sparesults/src/csv.rs index e45f521f..b0dc99f1 100644 --- a/lib/sparesults/src/csv.rs +++ b/lib/sparesults/src/csv.rs @@ -475,6 +475,8 @@ impl LineReader { #[cfg(test)] mod tests { + #![allow(clippy::panic_in_result_fn)] + use super::*; use std::error::Error; use std::rc::Rc; diff --git a/lib/src/sparql/eval.rs b/lib/src/sparql/eval.rs index e21ee891..6f52228d 100644 --- a/lib/src/sparql/eval.rs +++ b/lib/src/sparql/eval.rs @@ -5873,7 +5873,10 @@ impl Timer { #[cfg(test)] mod tests { + #![allow(clippy::panic_in_result_fn)] + use super::*; + #[test] fn uuid() { let mut buffer = String::default(); diff --git a/lib/src/storage/binary_encoder.rs b/lib/src/storage/binary_encoder.rs index cd2272dd..c06a8d7e 100644 --- a/lib/src/storage/binary_encoder.rs +++ b/lib/src/storage/binary_encoder.rs @@ -633,6 +633,8 @@ pub fn write_term(sink: &mut Vec, term: &EncodedTerm) { #[cfg(test)] mod tests { + #![allow(clippy::panic_in_result_fn)] + use super::*; use crate::model::TermRef; use crate::storage::numeric_encoder::*; diff --git a/lib/tests/store.rs b/lib/tests/store.rs index e17fb69c..c9e67bfb 100644 --- a/lib/tests/store.rs +++ b/lib/tests/store.rs @@ -291,15 +291,15 @@ fn test_bad_stt_open() -> Result<(), Box> { let dir = TempDir::default(); let store = Store::open(&dir.0)?; remove_dir_all(&dir.0)?; - assert!(store + store .bulk_loader() .load_quads(once(Quad::new( NamedNode::new_unchecked("http://example.com/s"), NamedNode::new_unchecked("http://example.com/p"), NamedNode::new_unchecked("http://example.com/o"), - GraphName::DefaultGraph + GraphName::DefaultGraph, ))) - .is_err()); + .unwrap_err(); Ok(()) } @@ -350,7 +350,7 @@ fn test_bad_backup() -> Result<(), Box> { let backup_dir = TempDir::default(); create_dir_all(&backup_dir.0)?; - assert!(Store::open(&store_dir)?.backup(&backup_dir.0).is_err()); + Store::open(&store_dir)?.backup(&backup_dir.0).unwrap_err(); Ok(()) } @@ -358,7 +358,7 @@ fn test_bad_backup() -> Result<(), Box> { #[cfg(not(target_family = "wasm"))] fn test_backup_on_in_memory() -> Result<(), Box> { let backup_dir = TempDir::default(); - assert!(Store::new()?.backup(&backup_dir).is_err()); + Store::new()?.backup(&backup_dir).unwrap_err(); Ok(()) }