CI: Run clippy on all targets

pull/660/head
Tpt 1 year ago committed by Thomas Tanon
parent 5647624012
commit ea80c11d6e
  1. 24
      .github/workflows/tests.yml
  2. 2
      cli/src/main.rs
  3. 16
      lib/oxrdf/src/blank_node.rs
  4. 67
      lib/oxrdf/src/dataset.rs
  5. 2
      lib/oxrdf/src/literal.rs
  6. 29
      lib/oxrdfxml/src/serializer.rs
  7. 2
      lib/oxsdatatypes/src/boolean.rs
  8. 11
      lib/oxsdatatypes/src/date_time.rs
  9. 42
      lib/oxsdatatypes/src/decimal.rs
  10. 2
      lib/oxsdatatypes/src/double.rs
  11. 2
      lib/oxsdatatypes/src/duration.rs
  12. 2
      lib/oxsdatatypes/src/float.rs
  13. 28
      lib/oxsdatatypes/src/integer.rs
  14. 2
      lib/oxttl/src/trig.rs
  15. 2
      lib/oxttl/src/turtle.rs
  16. 2
      lib/sparesults/src/csv.rs
  17. 3
      lib/src/sparql/eval.rs
  18. 2
      lib/src/storage/binary_encoder.rs
  19. 10
      lib/tests/store.rs

@ -28,29 +28,29 @@ jobs:
submodules: true submodules: true
- run: rustup update && rustup default 1.70.0 && rustup component add clippy - run: rustup update && rustup default 1.70.0 && rustup component add clippy
- uses: Swatinem/rust-cache@v2 - 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 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 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 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 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 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 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 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 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 working-directory: ./lib
- run: cargo clippy -- -D warnings -D clippy::all - run: cargo clippy --all-targets -- -D warnings -D clippy::all
working-directory: ./python working-directory: ./python
- run: cargo clippy -- -D warnings -D clippy::all - run: cargo clippy --all-targets -- -D warnings -D clippy::all
working-directory: ./cli working-directory: ./cli
- run: cargo clippy -- -D warnings -D clippy::all - run: cargo clippy --all-targets -- -D warnings -D clippy::all
working-directory: ./testsuite working-directory: ./testsuite
clippy_wasm_js: clippy_wasm_js:

@ -1818,6 +1818,8 @@ fn systemd_notify_ready() -> io::Result<()> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::panic_in_result_fn)]
use super::*; use super::*;
use anyhow::Result; use anyhow::Result;
use assert_cmd::Command; use assert_cmd::Command;

@ -363,6 +363,8 @@ impl Error for BlankNodeIdParseError {}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::panic_in_result_fn)]
use super::*; use super::*;
#[test] #[test]
@ -379,13 +381,13 @@ mod tests {
#[test] #[test]
fn new_validation() { fn new_validation() {
assert!(BlankNode::new("").is_err()); BlankNode::new("").unwrap_err();
assert!(BlankNode::new("a").is_ok()); BlankNode::new("a").unwrap();
assert!(BlankNode::new("-").is_err()); BlankNode::new("-").unwrap_err();
assert!(BlankNode::new("a-").is_ok()); BlankNode::new("a-").unwrap();
assert!(BlankNode::new(".").is_err()); BlankNode::new(".").unwrap_err();
assert!(BlankNode::new("a.").is_err()); BlankNode::new("a.").unwrap_err();
assert!(BlankNode::new("a.a").is_ok()); BlankNode::new("a.a").unwrap();
} }
#[test] #[test]

@ -1567,35 +1567,40 @@ type QuadsPerBlankNode = HashMap<
)>, )>,
>; >;
#[test] #[cfg(test)]
fn test_canon() { mod tests {
let mut dataset = Dataset::new(); use super::*;
dataset.insert(QuadRef::new(
BlankNode::default().as_ref(), #[test]
NamedNodeRef::new_unchecked("http://ex"), fn test_canon() {
BlankNode::default().as_ref(), let mut dataset = Dataset::new();
GraphNameRef::DefaultGraph, dataset.insert(QuadRef::new(
)); BlankNode::default().as_ref(),
dataset.insert(QuadRef::new( NamedNodeRef::new_unchecked("http://ex"),
BlankNode::default().as_ref(), BlankNode::default().as_ref(),
NamedNodeRef::new_unchecked("http://ex"), GraphNameRef::DefaultGraph,
BlankNode::default().as_ref(), ));
GraphNameRef::DefaultGraph, dataset.insert(QuadRef::new(
)); BlankNode::default().as_ref(),
dataset.canonicalize(); NamedNodeRef::new_unchecked("http://ex"),
let mut dataset2 = Dataset::new(); BlankNode::default().as_ref(),
dataset2.insert(QuadRef::new( GraphNameRef::DefaultGraph,
BlankNode::default().as_ref(), ));
NamedNodeRef::new_unchecked("http://ex"), dataset.canonicalize();
BlankNode::default().as_ref(), let mut dataset2 = Dataset::new();
GraphNameRef::DefaultGraph, dataset2.insert(QuadRef::new(
)); BlankNode::default().as_ref(),
dataset2.insert(QuadRef::new( NamedNodeRef::new_unchecked("http://ex"),
BlankNode::default().as_ref(), BlankNode::default().as_ref(),
NamedNodeRef::new_unchecked("http://ex"), GraphNameRef::DefaultGraph,
BlankNode::default().as_ref(), ));
GraphNameRef::DefaultGraph, dataset2.insert(QuadRef::new(
)); BlankNode::default().as_ref(),
dataset2.canonicalize(); NamedNodeRef::new_unchecked("http://ex"),
assert_eq!(dataset, dataset2); BlankNode::default().as_ref(),
GraphNameRef::DefaultGraph,
));
dataset2.canonicalize();
assert_eq!(dataset, dataset2);
}
} }

@ -636,6 +636,8 @@ pub fn print_quoted_str(string: &str, f: &mut impl Write) -> fmt::Result {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::panic_in_result_fn)]
use super::*; use super::*;
#[test] #[test]

@ -338,16 +338,21 @@ fn split_iri(iri: &str) -> (&str, &str) {
} }
} }
#[test] #[cfg(test)]
fn test_split_iri() { mod tests {
assert_eq!( use super::*;
split_iri("http://schema.org/Person"),
("http://schema.org/", "Person") #[test]
); fn test_split_iri() {
assert_eq!(split_iri("http://schema.org/"), ("http://schema.org/", "")); assert_eq!(
assert_eq!( split_iri("http://schema.org/Person"),
split_iri("http://schema.org#foo"), ("http://schema.org/", "Person")
("http://schema.org#", "foo") );
); assert_eq!(split_iri("http://schema.org/"), ("http://schema.org/", ""));
assert_eq!(split_iri("urn:isbn:foo"), ("urn:isbn:", "foo")); assert_eq!(
split_iri("http://schema.org#foo"),
("http://schema.org#", "foo")
);
assert_eq!(split_iri("urn:isbn:foo"), ("urn:isbn:", "foo"));
}
} }

@ -85,6 +85,8 @@ impl fmt::Display for Boolean {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::panic_in_result_fn)]
use super::*; use super::*;
#[test] #[test]

@ -2452,6 +2452,8 @@ impl Error for InvalidTimezoneError {}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::panic_in_result_fn)]
use super::*; use super::*;
#[test] #[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+01:00")?.to_string(), "--01+01:00");
assert_eq!(GMonth::from_str("--01")?.to_string(), "--01"); assert_eq!(GMonth::from_str("--01")?.to_string(), "--01");
assert!(GYear::from_str("02020").is_err()); GYear::from_str("02020").unwrap_err();
assert!(GYear::from_str("+2020").is_err()); GYear::from_str("+2020").unwrap_err();
assert!(GYear::from_str("33").is_err()); GYear::from_str("33").unwrap_err();
assert_eq!(Time::from_str("00:00:00+14:00")?, Time::MIN); assert_eq!(Time::from_str("00:00:00+14:00")?, Time::MIN);
assert_eq!(Time::from_str("24:00:00-14:00")?, Time::MAX); assert_eq!(Time::from_str("24:00:00-14:00")?, Time::MAX);
@ -3155,10 +3157,9 @@ mod tests {
} }
#[test] #[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::MIN), GYearMonth::MIN);
assert_eq!(GYearMonth::from(Date::MAX), GYearMonth::MAX); assert_eq!(GYearMonth::from(Date::MAX), GYearMonth::MAX);
Ok(())
} }
#[test] #[test]

@ -674,6 +674,8 @@ impl Error for TooLargeForDecimalError {}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::panic_in_result_fn)]
use super::*; use super::*;
#[test] #[test]
@ -688,14 +690,14 @@ mod tests {
#[test] #[test]
fn from_str() -> Result<(), ParseDecimalError> { fn from_str() -> Result<(), ParseDecimalError> {
assert!(Decimal::from_str("").is_err()); Decimal::from_str("").unwrap_err();
assert!(Decimal::from_str("+").is_err()); Decimal::from_str("+").unwrap_err();
assert!(Decimal::from_str("-").is_err()); Decimal::from_str("-").unwrap_err();
assert!(Decimal::from_str(".").is_err()); Decimal::from_str(".").unwrap_err();
assert!(Decimal::from_str("+.").is_err()); Decimal::from_str("+.").unwrap_err();
assert!(Decimal::from_str("-.").is_err()); Decimal::from_str("-.").unwrap_err();
assert!(Decimal::from_str("a").is_err()); Decimal::from_str("a").unwrap_err();
assert!(Decimal::from_str(".a").is_err()); Decimal::from_str(".a").unwrap_err();
assert_eq!(Decimal::from_str("210")?.to_string(), "210"); assert_eq!(Decimal::from_str("210")?.to_string(), "210");
assert_eq!(Decimal::from_str("1000")?.to_string(), "1000"); assert_eq!(Decimal::from_str("1000")?.to_string(), "1000");
assert_eq!(Decimal::from_str("-1.23")?.to_string(), "-1.23"); 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("-0")?.to_string(), "0");
assert_eq!(Decimal::from_str(&Decimal::MAX.to_string())?, Decimal::MAX); assert_eq!(Decimal::from_str(&Decimal::MAX.to_string())?, Decimal::MAX);
assert_eq!(Decimal::from_str(&Decimal::MIN.to_string())?, Decimal::MIN); assert_eq!(Decimal::from_str(&Decimal::MIN.to_string())?, Decimal::MIN);
assert!(Decimal::from_str("0.0000000000000000001").is_err()); Decimal::from_str("0.0000000000000000001").unwrap_err();
assert!(Decimal::from_str("1000000000000000000000").is_err()); Decimal::from_str("1000000000000000000000").unwrap_err();
assert_eq!( assert_eq!(
Decimal::from_str("0.100000000000000000000000000").unwrap(), Decimal::from_str("0.100000000000000000000000000").unwrap(),
Decimal::from_str("0.1").unwrap() Decimal::from_str("0.1").unwrap()
@ -1019,11 +1021,11 @@ mod tests {
Decimal::try_from(Float::from(-123.5)).ok(), Decimal::try_from(Float::from(-123.5)).ok(),
Some(Decimal::from_str("-123.5")?) Some(Decimal::from_str("-123.5")?)
); );
assert!(Decimal::try_from(Float::from(f32::NAN)).is_err()); Decimal::try_from(Float::from(f32::NAN)).unwrap_err();
assert!(Decimal::try_from(Float::from(f32::INFINITY)).is_err()); Decimal::try_from(Float::from(f32::INFINITY)).unwrap_err();
assert!(Decimal::try_from(Float::from(f32::NEG_INFINITY)).is_err()); Decimal::try_from(Float::from(f32::NEG_INFINITY)).unwrap_err();
assert!(Decimal::try_from(Float::from(f32::MIN)).is_err()); Decimal::try_from(Float::from(f32::MIN)).unwrap_err();
assert!(Decimal::try_from(Float::from(f32::MAX)).is_err()); Decimal::try_from(Float::from(f32::MAX)).unwrap_err();
assert!( assert!(
Decimal::try_from(Float::from(1_672_507_300_000.)) Decimal::try_from(Float::from(1_672_507_300_000.))
.unwrap() .unwrap()
@ -1059,11 +1061,11 @@ mod tests {
.unwrap() .unwrap()
< Decimal::from(1) < Decimal::from(1)
); );
assert!(Decimal::try_from(Double::from(f64::NAN)).is_err()); Decimal::try_from(Double::from(f64::NAN)).unwrap_err();
assert!(Decimal::try_from(Double::from(f64::INFINITY)).is_err()); Decimal::try_from(Double::from(f64::INFINITY)).unwrap_err();
assert!(Decimal::try_from(Double::from(f64::NEG_INFINITY)).is_err()); Decimal::try_from(Double::from(f64::NEG_INFINITY)).unwrap_err();
assert!(Decimal::try_from(Double::from(f64::MIN)).is_err()); Decimal::try_from(Double::from(f64::MIN)).unwrap_err();
assert!(Decimal::try_from(Double::from(f64::MAX)).is_err()); Decimal::try_from(Double::from(f64::MAX)).unwrap_err();
Ok(()) Ok(())
} }

@ -261,6 +261,8 @@ impl Div for Double {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::panic_in_result_fn)]
use super::*; use super::*;
#[test] #[test]

@ -996,6 +996,8 @@ impl From<OppositeSignInDurationComponentsError> for ParseDurationError {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::panic_in_result_fn)]
use super::*; use super::*;
#[test] #[test]

@ -251,6 +251,8 @@ impl Div for Float {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::panic_in_result_fn)]
use super::*; use super::*;
#[test] #[test]

@ -278,6 +278,8 @@ impl Error for TooLargeForIntegerError {}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::panic_in_result_fn)]
use super::*; use super::*;
#[test] #[test]
@ -286,7 +288,7 @@ mod tests {
assert_eq!(Integer::from_str("-0")?.to_string(), "0"); 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_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(()) Ok(())
} }
@ -304,11 +306,11 @@ mod tests {
Integer::try_from(Float::from(-123.1)).ok(), Integer::try_from(Float::from(-123.1)).ok(),
Some(Integer::from_str("-123")?) Some(Integer::from_str("-123")?)
); );
assert!(Integer::try_from(Float::from(f32::NAN)).is_err()); Integer::try_from(Float::from(f32::NAN)).unwrap_err();
assert!(Integer::try_from(Float::from(f32::INFINITY)).is_err()); Integer::try_from(Float::from(f32::INFINITY)).unwrap_err();
assert!(Integer::try_from(Float::from(f32::NEG_INFINITY)).is_err()); Integer::try_from(Float::from(f32::NEG_INFINITY)).unwrap_err();
assert!(Integer::try_from(Float::from(f32::MIN)).is_err()); Integer::try_from(Float::from(f32::MIN)).unwrap_err();
assert!(Integer::try_from(Float::from(f32::MAX)).is_err()); Integer::try_from(Float::from(f32::MAX)).unwrap_err();
assert!( assert!(
Integer::try_from(Float::from(1_672_507_300_000.)) Integer::try_from(Float::from(1_672_507_300_000.))
.unwrap() .unwrap()
@ -344,11 +346,11 @@ mod tests {
.unwrap() .unwrap()
< Integer::from(10) < Integer::from(10)
); );
assert!(Integer::try_from(Double::from(f64::NAN)).is_err()); Integer::try_from(Double::from(f64::NAN)).unwrap_err();
assert!(Integer::try_from(Double::from(f64::INFINITY)).is_err()); Integer::try_from(Double::from(f64::INFINITY)).unwrap_err();
assert!(Integer::try_from(Double::from(f64::NEG_INFINITY)).is_err()); Integer::try_from(Double::from(f64::NEG_INFINITY)).unwrap_err();
assert!(Integer::try_from(Double::from(f64::MIN)).is_err()); Integer::try_from(Double::from(f64::MIN)).unwrap_err();
assert!(Integer::try_from(Double::from(f64::MAX)).is_err()); Integer::try_from(Double::from(f64::MAX)).unwrap_err();
Ok(()) Ok(())
} }
@ -362,8 +364,8 @@ mod tests {
Integer::try_from(Decimal::from_str("-123.1").unwrap()).ok(), Integer::try_from(Decimal::from_str("-123.1").unwrap()).ok(),
Some(Integer::from_str("-123")?) Some(Integer::from_str("-123")?)
); );
assert!(Integer::try_from(Decimal::MIN).is_err()); Integer::try_from(Decimal::MIN).unwrap_err();
assert!(Integer::try_from(Decimal::MAX).is_err()); Integer::try_from(Decimal::MAX).unwrap_err();
Ok(()) Ok(())
} }

@ -860,6 +860,8 @@ fn is_turtle_double(value: &str) -> bool {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::panic_in_result_fn)]
use super::*; use super::*;
use oxrdf::vocab::xsd; use oxrdf::vocab::xsd;
use oxrdf::{BlankNodeRef, GraphNameRef, LiteralRef, NamedNodeRef}; use oxrdf::{BlankNodeRef, GraphNameRef, LiteralRef, NamedNodeRef};

@ -666,6 +666,8 @@ impl LowLevelTurtleWriter {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::panic_in_result_fn)]
use super::*; use super::*;
use oxrdf::{BlankNodeRef, LiteralRef, NamedNodeRef}; use oxrdf::{BlankNodeRef, LiteralRef, NamedNodeRef};

@ -475,6 +475,8 @@ impl LineReader {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::panic_in_result_fn)]
use super::*; use super::*;
use std::error::Error; use std::error::Error;
use std::rc::Rc; use std::rc::Rc;

@ -5873,7 +5873,10 @@ impl Timer {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::panic_in_result_fn)]
use super::*; use super::*;
#[test] #[test]
fn uuid() { fn uuid() {
let mut buffer = String::default(); let mut buffer = String::default();

@ -633,6 +633,8 @@ pub fn write_term(sink: &mut Vec<u8>, term: &EncodedTerm) {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::panic_in_result_fn)]
use super::*; use super::*;
use crate::model::TermRef; use crate::model::TermRef;
use crate::storage::numeric_encoder::*; use crate::storage::numeric_encoder::*;

@ -291,15 +291,15 @@ fn test_bad_stt_open() -> Result<(), Box<dyn Error>> {
let dir = TempDir::default(); let dir = TempDir::default();
let store = Store::open(&dir.0)?; let store = Store::open(&dir.0)?;
remove_dir_all(&dir.0)?; remove_dir_all(&dir.0)?;
assert!(store store
.bulk_loader() .bulk_loader()
.load_quads(once(Quad::new( .load_quads(once(Quad::new(
NamedNode::new_unchecked("http://example.com/s"), NamedNode::new_unchecked("http://example.com/s"),
NamedNode::new_unchecked("http://example.com/p"), NamedNode::new_unchecked("http://example.com/p"),
NamedNode::new_unchecked("http://example.com/o"), NamedNode::new_unchecked("http://example.com/o"),
GraphName::DefaultGraph GraphName::DefaultGraph,
))) )))
.is_err()); .unwrap_err();
Ok(()) Ok(())
} }
@ -350,7 +350,7 @@ fn test_bad_backup() -> Result<(), Box<dyn Error>> {
let backup_dir = TempDir::default(); let backup_dir = TempDir::default();
create_dir_all(&backup_dir.0)?; 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(()) Ok(())
} }
@ -358,7 +358,7 @@ fn test_bad_backup() -> Result<(), Box<dyn Error>> {
#[cfg(not(target_family = "wasm"))] #[cfg(not(target_family = "wasm"))]
fn test_backup_on_in_memory() -> Result<(), Box<dyn Error>> { fn test_backup_on_in_memory() -> Result<(), Box<dyn Error>> {
let backup_dir = TempDir::default(); let backup_dir = TempDir::default();
assert!(Store::new()?.backup(&backup_dir).is_err()); Store::new()?.backup(&backup_dir).unwrap_err();
Ok(()) Ok(())
} }

Loading…
Cancel
Save