Skip to content

Commit

Permalink
add typos conguration and CI action
Browse files Browse the repository at this point in the history
fix #168
  • Loading branch information
pchampin committed Jun 11, 2024
1 parent e8bb39e commit 675fb9c
Show file tree
Hide file tree
Showing 32 changed files with 84 additions and 69 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/lint_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: Lint and Test

on: [push, pull_request]
Expand All @@ -8,7 +7,7 @@ jobs:
name: fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- run: rustup update
- run: rustup component add rustfmt
- run: cargo fmt -- --check
Expand All @@ -17,19 +16,25 @@ jobs:
name: clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- run: rustup update
- run: rustup component add clippy
- run: cargo clippy --all --all-targets --all-features

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
with:
submodules: true
- run: rustup update
- run: cargo build --all-features
- run: cargo test --verbose --all --all-features
env:
RUST_BACKTRACE: 1
RUST_BACKTRACE: 1

typos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: crate-ci/typos@master
4 changes: 2 additions & 2 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
- new API for prefix map
- new IRI wrappers and traits in sophia_iri
- Serializers for Turtle and TriG (with 2 modes: fast and pretty)
Oher major changes
Other major changes
- Now entirely modular: sophia is essentially only a compilation
of smaller crates
Documentation
Expand Down Expand Up @@ -95,7 +95,7 @@
- Common traits for parsers and serializers
- More idiomatic API for Triple- and QuadSource
Dev
- reduced dependancies (coercible-errors, error-chain, pest)
- reduced dependencies (coercible-errors, error-chain, pest)
- no more central Error type

0.3.0
Expand Down
2 changes: 1 addition & 1 deletion api/src/dataset/_foreign_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ impl<T: Quad, S> SetDataset for HashSet<T, S> {}

// BTreeSet of quads

/// NB: This is a straighforward and minimal implementation,
/// NB: This is a straightforward and minimal implementation,
/// not taking advantage of the order of terms to optimize [`Dataset::quads_matching`]
/// nor other methods.
impl<Q: Quad> Dataset for BTreeSet<Q> {
Expand Down
2 changes: 1 addition & 1 deletion api/src/graph/_foreign_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ impl<T: Triple, S> SetGraph for HashSet<T, S> {}

// BTreeSet of triples

/// NB: This is a straighforward and minimal implementation,
/// NB: This is a straightforward and minimal implementation,
/// not taking advantage of the order of terms to optimize [`Graph::triples_matching`]
/// nor other methods.
impl<T: Triple> Graph for BTreeSet<T> {
Expand Down
2 changes: 1 addition & 1 deletion api/src/ns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ mod test {
let ns1 = Namespace::new("http://schema.org/").unwrap();
assert_ne!(
ns1.get("name").unwrap().to_string(),
ns1.get("nam").unwrap().to_string()
ns1.get("givenName").unwrap().to_string()
);
}

Expand Down
2 changes: 1 addition & 1 deletion api/src/ns/_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ macro_rules! namespace {
$crate::ns_iri!(PREFIX, $r_id, $r_sf);
)*

/// Test module for checking tha IRIs are valid
/// Test module for checking that IRIs are valid
#[cfg(test)]
mod test_valid_iri {
$(
Expand Down
6 changes: 3 additions & 3 deletions api/src/sparql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub trait SparqlDataset {
type SparqlError: Error + 'static;
/// The type representing pre-processed queries.
///
/// See [`prepare_query`](#tymethod.prepare_query) for more defail.
/// See [`prepare_query`](#tymethod.prepare_query) for more detail.
type Query: Query<Error = Self::SparqlError>;

/// Parse and immediately execute `query`.
Expand All @@ -61,7 +61,7 @@ pub trait SparqlDataset {
///
/// This allows some implementation to separate parsing,
/// (or any other pre-processing step)
/// of the query string from the actual exectution of the query.
/// of the query string from the actual execution of the query.
/// There is however no guarantee on how much pre-processing is actually done by this method
/// (see below).
///
Expand Down Expand Up @@ -96,7 +96,7 @@ impl Query for String {
/// A utility trait to allow [`SparqlDataset::query`]
/// to accept either `&str` or [`Self::Query`](SparqlDataset::Query).
pub trait IntoQuery<Q: Query> {
/// The ouput type of [`into_query`](IntoQuery::into_query).
/// The output type of [`into_query`](IntoQuery::into_query).
type Out: Borrow<Q>;
/// Convert `self` to a [`Query`].
fn into_query(self) -> Result<Self::Out, Q::Error>;
Expand Down
18 changes: 9 additions & 9 deletions api/src/term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub enum TermKind {
/// However, while all other methods have a default implementtation (returning `None`),
/// those corresponding to the supported kinds MUST be overridden accordingly,
/// otherwise they will panic.
/// See below for an explaination of this design choice.
/// See below for an explanation of this design choice.
///
/// In order to test that all the methods are implemented consistently,
/// consider using the macro [`assert_consistent_term_impl`].
Expand All @@ -71,7 +71,7 @@ pub enum TermKind {
///
/// # Design rationale
///
/// The methods defined by this trait are not independant:
/// The methods defined by this trait are not independent:
/// depending on the value returned by [`kind`](Term::kind),
/// other methods are expected to return `Some(...)` or `None` accordingly.
///
Expand Down Expand Up @@ -111,28 +111,28 @@ pub trait Term: std::fmt::Debug {
fn kind(&self) -> TermKind;

/// Return true if this [`Term`] is an IRI,
/// i.e. if [`kind`](Term::kind) retuns [`TermKind::Iri`].
/// i.e. if [`kind`](Term::kind) returns [`TermKind::Iri`].
#[inline]
fn is_iri(&self) -> bool {
self.kind() == TermKind::Iri
}

/// Return true if this [`Term`] is a blank node,
/// i.e. if [`kind`](Term::kind) retuns [`TermKind::BlankNode`].
/// i.e. if [`kind`](Term::kind) returns [`TermKind::BlankNode`].
#[inline]
fn is_blank_node(&self) -> bool {
self.kind() == TermKind::BlankNode
}

/// Return true if this [`Term`] is a literal,
/// i.e. if [`kind`](Term::kind) retuns [`TermKind::Literal`].
/// i.e. if [`kind`](Term::kind) returns [`TermKind::Literal`].
#[inline]
fn is_literal(&self) -> bool {
self.kind() == TermKind::Literal
}

/// Return true if this [`Term`] is a variable,
/// i.e. if [`kind`](Term::kind) retuns [`TermKind::Variable`].
/// i.e. if [`kind`](Term::kind) returns [`TermKind::Variable`].
#[inline]
fn is_variable(&self) -> bool {
self.kind() == TermKind::Variable
Expand All @@ -153,7 +153,7 @@ pub trait Term: std::fmt::Debug {
}

/// Return true if this [`Term`] is an RDF-star quoted triple,
/// i.e. if [`kind`](Term::kind) retuns [`TermKind::Triple`].
/// i.e. if [`kind`](Term::kind) returns [`TermKind::Triple`].
#[inline]
fn is_triple(&self) -> bool {
self.kind() == TermKind::Triple
Expand Down Expand Up @@ -311,7 +311,7 @@ pub trait Term: std::fmt::Debug {
}
}

/// Iter over all the constiutents of this term, consuming it.
/// Iter over all the constituents of this term, consuming it.
///
/// See [Term::constituents].
fn to_constituents<'a>(self) -> Box<dyn Iterator<Item = Self> + 'a>
Expand Down Expand Up @@ -435,7 +435,7 @@ pub trait Term: std::fmt::Debug {
})
}

/// Compute an implementation-independant hash of this RDF term.
/// Compute an implementation-independent hash of this RDF term.
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
let k = self.kind();
k.hash(state);
Expand Down
4 changes: 2 additions & 2 deletions api/src/term/_cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ impl<T: Term> Term for CmpTerm<T> {
fn try_into_term<U: TryFromTerm>(self) -> Result<U, U::Error> {
self.0.try_into_term()
}
// NOT overridding the iterator methods
// NOT overriding the iterator methods
// (constituents, to_constituents, atoms, to_atoms)
// because this would introduce an additional Box<dyn ...> indirection,
// potentially hurting performances,
// beyond the benefit of a hypotherical custom impl of these methods in T.
// beyond the benefit of a hypothetical custom impl of these methods in T.
}

impl<T1: Term, T2: Term> PartialEq<T2> for CmpTerm<T1> {
Expand Down
2 changes: 1 addition & 1 deletion api/src/term/_simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ lazy_static::lazy_static! {
static ref RDF_LANG_STRING: Box<str> = rdf::langString.iri().unwrap().unwrap().into();
}

/// A straighforward implementation of [`Term`] as an enum.
/// A straightforward implementation of [`Term`] as an enum.
#[derive(Clone, Debug)]
pub enum SimpleTerm<'a> {
/// An [RDF IRI](https://www.w3.org/TR/rdf11-concepts/#section-IRIs)
Expand Down
2 changes: 1 addition & 1 deletion book/src/ch04_rdf_graphs.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ and are described in more detail in the [next chapter](./ch05_term_matchers.md).
* [`sophia::inmem::LightGraph`] provides a [`Graph`] and [`MutableGraph`] implementation with a low memory footprint;
* [`sophia::inmem::FastGraph`] provides a [`Graph`] and [`MutableGraph`] implementation designed for fast retrieval of any given triple.

## Recipies for constructing graphs
## Recipes for constructing graphs

### Constructing and populating an empty graph

Expand Down
16 changes: 8 additions & 8 deletions c14n/src/rdfc10.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub fn normalize_with<H: HashFunction, D: SetDataset, W: io::Write>(
let (mut quads, _) = relabel_with::<H, D>(d, depth_factor, permutation_limit)?;
let mut buf1 = String::new();
let mut buf2 = String::new();
// we sort the quads, but comparing the terms based on ther NQ serialization,
// we sort the quads, but comparing the terms based on their NQ serialization,
// which amounts to sorting the N-Quads lines without materializing them
quads.sort_unstable_by(|q1, q2| {
for (t1, t2) in iter_spog_opt(q1.spog()).zip(iter_spog_opt(q2.spog())) {
Expand Down Expand Up @@ -129,7 +129,7 @@ pub fn relabel_sha384<D: SetDataset>(
///
/// The parameters `depth_factor` and `permutation_limit`
/// are used to stop the algorithm if the computation becomes too complex,
/// in order to secure it agains [dataset poisoning](https://www.w3.org/TR/rdf-canon/#dataset-poisoning).
/// in order to secure it against [dataset poisoning](https://www.w3.org/TR/rdf-canon/#dataset-poisoning).
/// The default values ([`DEFAULT_DEPTH_FACTOR`]) and [`DEFAULT_PERMUTATION_LIMIT`])
/// are expected to work with any "realistic" dataset.
///
Expand Down Expand Up @@ -470,7 +470,7 @@ fn hash_first_degree_quads<H: HashFunction, Q: Quad>(bnid: &str, quads: &[&Q]) -
}
let ret = hasher.finalize();
debug_assert!({
eprintln!("hash-fisrt-degree({})\n-> {}", bnid, hex(&ret));
eprintln!("hash-first-degree({})\n-> {}", bnid, hex(&ret));
true
});
ret
Expand Down Expand Up @@ -723,13 +723,13 @@ _:c14n4 <http://example.com/#p> _:c14n3 .
Ok(unsafe { String::from_utf8_unchecked(output) })
}

/// Simplisitic Quad parser, useful for writing test cases.
/// Simplistic Quad parser, useful for writing test cases.
/// It is based on eq_quad below.
fn ez_quads<'a>(lines: &[&'a str]) -> std::collections::HashSet<Spog<SimpleTerm<'a>>> {
lines.iter().map(|line| ez_quad(line)).collect()
}

/// Simplisitic Quad parser, useful for writing test cases.
/// Simplistic Quad parser, useful for writing test cases.
/// The syntax is a subset of N-Quads-star,
/// where spaces are not allowed in literals, and a space is required before the ending '.'.
fn ez_quad(txt: &str) -> Spog<SimpleTerm> {
Expand Down Expand Up @@ -791,9 +791,9 @@ _:c14n4 <http://example.com/#p> _:c14n3 .
_:c14n0 <http://example.com/#t> <http://example.com/#u> .
_:c14n1 <http://example.com/#s> <http://example.com/#u> .
"#;
let mut dout = Vec::<u8>::new();
normalize_sha384(&dataset, &mut dout).unwrap();
let got = unsafe { String::from_utf8_unchecked(dout) };
let mut got = Vec::<u8>::new();
normalize_sha384(&dataset, &mut got).unwrap();
let got = unsafe { String::from_utf8_unchecked(got) };
println!(">>>> GOT\n{}>>>> EXPECTED\n{}<<<<", got, exp);
assert!(got == exp);
}
Expand Down
2 changes: 1 addition & 1 deletion inmem/src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl<I: Index> SimpleTermIndex<I> {
}
}

/// The numver of terms in this index
/// The number of terms in this index
pub fn len(&self) -> usize {
self.i2t.len()
}
Expand Down
2 changes: 1 addition & 1 deletion iri/src/_wrap_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
/// }
/// ```
///
/// Two [examples](crate::wrap_macro_examples) are availble,
/// Two [examples](crate::wrap_macro_examples) are available,
/// illustrating the members and trait implementation generated by this macro.
///
/// NB: the documentation of the wrapper will point to the documentation of the `new` method.
Expand Down
4 changes: 2 additions & 2 deletions iri/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//! This crate provides functions for validating IRIs and IRI references,
//! as well as for resolving IRI references agains a given base IRI.
//! as well as for resolving IRI references against a given base IRI.
//!
//! It is developed as a part of [Sophia],
//! an [RDF] and [Linked Data] toolkit in Rust,
//! but can be used independantly.
//! but can be used independently.
//!
//! # Feature gates
//!
Expand Down
4 changes: 2 additions & 2 deletions iri/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
//! this module publicly exports arrays of test data,
//! for the benefit of other crates.

/// Structure of an IRI referece.
/// See [`POSITIVIE_IRIS`](constant.POSITIVE_IRIS.html) for more details.
/// Structure of an IRI reference.
/// See [`POSITIVE_IRIS`](constant.POSITIVE_IRIS.html) for more details.
pub type IriRefStructure<'a> = (
bool,
Option<&'a str>,
Expand Down
6 changes: 3 additions & 3 deletions isomorphism/src/iso_term.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! I define [`IsoTerm`],
//! a [`Term`] wrapper implemting [`Ord`] and [`Eq`]
//! a [`Term`] wrapper implementing [`Ord`] and [`Eq`]
//! in a way that is convenient to compute graph/dataset isomorphism.
//!
//! More specifically, all blank nodes are considered equal.
Expand Down Expand Up @@ -75,11 +75,11 @@ impl<T: Term> Term for IsoTerm<T> {
fn try_into_term<U: TryFromTerm>(self) -> Result<U, U::Error> {
self.0.try_into_term()
}
// NOT overridding the iterator methods
// NOT overriding the iterator methods
// (constituents, to_constituents, atoms, to_atoms)
// because this would introduce an additional Box<dyn ...> indirection,
// potentially hurting performances,
// beyond the benefit of a hypotherical custom impl of these methods in T.
// beyond the benefit of a hypothetical custom impl of these methods in T.
}

impl<T1, T2> PartialEq<IsoTerm<T1>> for IsoTerm<T2>
Expand Down
2 changes: 1 addition & 1 deletion isomorphism/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
//!
//! are considered isomorphic by the algorithm of this crate,
//! because they have the same number of blank nodes and arcs,
//! and all of their blank nodes are locally indistinguisable
//! and all of their blank nodes are locally indistinguishable
//! (same number of incoming and outgoinc arcs,
//! linking them to undistinguishable blank nodes).
//!
Expand Down
2 changes: 1 addition & 1 deletion jsonld/src/serializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ where
pub type Jsonifier<L = NoLoader> = JsonLdSerializer<JsonTarget, L>;

/// This type is just a placeholder [`JsonLdSerializer`]
/// targetting a [`JsonValue`].
/// targeting a [`JsonValue`].
/// See [`new_jsonifier`] and [`new_jsonifier_with`].
///
/// [`new_jsonifier`]: struct.JsonLdSerializer.html#method.new_jsonifier
Expand Down
2 changes: 1 addition & 1 deletion jsonld/src/serializer/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl<'a, L> Engine<'a, L> {
|| (self.options.rdf_direction() == Some(RdfDirection::CompoundLiteral)
&& self.compound_literals.contains(&inode))
{
//println!("=== skiped (list node or compound literal)");
//println!("=== skipped (list node or compound literal)");
return Ok(None);
}
//println!("=== --- doing it");
Expand Down
2 changes: 1 addition & 1 deletion jsonld/src/vocabulary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub type ArcTag = sophia_api::term::LanguageTag<Arc<str>>;
/// A [`Vocabulary`](rdf_types::Vocabulary) using `Arc<str>`-based types as index.
///
/// These types match the notion of index in [`rdf_types`] as they are relatively cheap to clone,
/// but offer the advantage of being self-explanatory, and resolvable to actual terms withour actually needing the vocabulary.
/// but offer the advantage of being self-explanatory, and resolvable to actual terms without actually needing the vocabulary.
#[derive(Clone, Debug, Default)]
pub struct ArcVoc {}

Expand Down
2 changes: 1 addition & 1 deletion resource/src/loader/_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::sync::Arc;
/// A resource loader using local versions of the resources.
///
/// It guesses content-type from the file extensions,
/// and emulates content-negociation :
/// and emulates content-negotiation :
/// if a resource is not found, it will try adding a few well-known extensions to it.
#[derive(Clone, Debug, Default)]
pub struct LocalLoader {
Expand Down
Loading

0 comments on commit 675fb9c

Please sign in to comment.