Makes new Clippy happy

pull/816/head
Tpt 10 months ago committed by Thomas Tanon
parent c57615519b
commit bd5e54a00a
  1. 10
      fuzz/fuzz_targets/rdf_xml.rs
  2. 2
      fuzz/fuzz_targets/sparql_eval.rs
  3. 20
      fuzz/fuzz_targets/trig.rs
  4. 2
      fuzz/src/result_format.rs
  5. 6
      lib/oxrdfxml/src/parser.rs
  6. 10
      lib/sparesults/src/xml.rs
  7. 10
      lints/test_debian_compatibility.py

@ -5,12 +5,10 @@ use oxrdfxml::{RdfXmlParser, RdfXmlSerializer};
fuzz_target!(|data: &[u8]| {
// We parse
let mut triples = Vec::new();
for triple in RdfXmlParser::new().parse_read(data) {
if let Ok(triple) = triple {
triples.push(triple);
}
}
let triples = RdfXmlParser::new()
.parse_read(data)
.flatten()
.collect::<Vec<_>>();
// We serialize
let mut writer = RdfXmlSerializer::new().serialize_to_write(Vec::new());

@ -11,7 +11,7 @@ fuzz_target!(|data: sparql_smith::Query| {
let store = STORE.get_or_init(|| {
let store = Store::new().unwrap();
store
.load_dataset(sparql_smith::DATA_TRIG.as_bytes(), RdfFormat::TriG, None)
.load_from_read(RdfFormat::TriG, sparql_smith::DATA_TRIG.as_bytes())
.unwrap();
store
});

@ -130,17 +130,15 @@ fuzz_target!(|data: &[u8]| {
String::from_utf8_lossy(&serialize_quads(&quads_without_split, Vec::new()))
);
if errors.is_empty() {
if errors.is_empty() {
let mut dataset_unchecked = quads_unchecked.iter().collect::<Dataset>();
dataset_unchecked.canonicalize();
assert_eq!(
dataset_with_split,
dataset_unchecked,
"Validating:\n{}\nUnchecked:\n{}",
String::from_utf8_lossy(&serialize_quads(&quads, Vec::new())),
String::from_utf8_lossy(&serialize_quads(&quads_unchecked, Vec::new()))
);
}
let mut dataset_unchecked = quads_unchecked.iter().collect::<Dataset>();
dataset_unchecked.canonicalize();
assert_eq!(
dataset_with_split,
dataset_unchecked,
"Validating:\n{}\nUnchecked:\n{}",
String::from_utf8_lossy(&serialize_quads(&quads, Vec::new())),
String::from_utf8_lossy(&serialize_quads(&quads_unchecked, Vec::new()))
);
}
}
assert_eq!(errors, errors_without_split);

@ -21,7 +21,7 @@ pub fn fuzz_result_format(format: QueryResultsFormat, data: &[u8]) {
.serialize_solutions_to_write(
Vec::new(),
solutions
.get(0)
.first()
.map_or_else(Vec::new, |s| s.variables().to_vec()),
)
.unwrap();

@ -499,8 +499,8 @@ impl<R> RdfXmlReader<R> {
})?;
// Resolves custom entities within the current entity definition.
let entity_value = unescape_with(entity_value, |e| self.resolve_entity(e))
.map_err(quick_xml::Error::from)?;
let entity_value =
unescape_with(entity_value, |e| self.resolve_entity(e)).map_err(Error::from)?;
self.custom_entities
.insert(entity_name.to_owned(), entity_value.to_string());
}
@ -921,7 +921,7 @@ impl<R> RdfXmlReader<R> {
Ok(unescape_with(&self.reader.decoder().decode(&value)?, |e| {
self.resolve_entity(e)
})
.map_err(quick_xml::Error::from)?
.map_err(Error::from)?
.to_string())
}
ResolveResult::Unbound => {

@ -5,7 +5,7 @@ use oxrdf::vocab::rdf;
use oxrdf::*;
use quick_xml::escape::unescape;
use quick_xml::events::{BytesDecl, BytesEnd, BytesStart, BytesText, Event};
use quick_xml::{Decoder, Reader, Writer};
use quick_xml::{Decoder, Error, Reader, Writer};
use std::collections::BTreeMap;
use std::io::{self, BufReader, Read, Write};
use std::mem::take;
@ -579,7 +579,7 @@ impl XmlInnerSolutionsReader {
Ok(None)
} else if event.local_name().as_ref() == b"literal" {
for attr in event.attributes() {
let attr = attr.map_err(quick_xml::Error::from)?;
let attr = attr.map_err(Error::from)?;
if attr.key.as_ref() == b"xml:lang" {
self.lang = Some(
unescape(&self.decoder.decode(&attr.value)?)?.into_owned(),
@ -822,12 +822,12 @@ fn build_literal(
}
}
fn map_xml_error(error: quick_xml::Error) -> io::Error {
fn map_xml_error(error: Error) -> io::Error {
match error {
quick_xml::Error::Io(error) => {
Error::Io(error) => {
Arc::try_unwrap(error).unwrap_or_else(|error| io::Error::new(error.kind(), error))
}
quick_xml::Error::UnexpectedEof(_) => io::Error::new(io::ErrorKind::UnexpectedEof, error),
Error::UnexpectedEof(_) => io::Error::new(io::ErrorKind::UnexpectedEof, error),
_ => io::Error::new(io::ErrorKind::InvalidData, error),
}
}

@ -41,13 +41,9 @@ def fetch_debian_package_desc(debian_name):
with urlopen(url) as response:
return json.loads(response.read().decode())
except HTTPError as e:
if e.code / 100 == 5:
wait = 2**i
print(f"Error {e} from {url}, retrying after {wait}s")
sleep(wait)
else:
print(f"Failed to fetch debian name {debian_name} from {url}: {e}")
raise e
wait = 2**i
print(f"Error {e} from {url}, retrying after {wait}s")
sleep(wait)
raise Exception(f"Failed to fetch {url}")

Loading…
Cancel
Save