Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(lint): run typos-cli on project #832

Merged
merged 6 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ This name should be decided amongst the team before the release.
- [#785](https://github.com/tweag/topiary/pull/785) Added the `coverage` command, that checks how much of the query file is used by the input.
- [#786](https://github.com/tweag/topiary/pull/786) Re-introduce tests to check that all of the language queries are useful.
- [#747](https://github.com/tweag/topiary/pull/747) Added support for specifying paths to prebuilt grammars in Topiary's configuration
- [#832](https://github.com/tweag/topiary/pull/832) Added `typos-cli` to workspace `Cargo.toml` for spellchecking @mkatychev

### Changed
- [#794](https://github.com/tweag/topiary/pull/794) Bump the `tree-sitter` dependency to 0.24 @ZedThree
Expand Down Expand Up @@ -81,7 +82,7 @@ This name should be decided amongst the team before the release.
### Changed
- [#704](https://github.com/tweag/topiary/pull/704) Refactors our postprocessing code to be more versatile.
- [#711](https://github.com/tweag/topiary/pull/711) Feature gate all grammars, with supported and contributed languages built by default.
- [#716](https://github.com/tweag/topiary/pull/716) Dynamicly fetch, compile, and load language grammars. Topiary now no longer ships with statically linked grammars.
- [#716](https://github.com/tweag/topiary/pull/716) Dynamically fetch, compile, and load language grammars. Topiary now no longer ships with statically linked grammars.
- [#732](https://github.com/tweag/topiary/pull/732) Change how function application and parenthesized expressions are treated in Nickel to reduce the overall noise and indentation
- [#736](https://github.com/tweag/topiary/pull/668) Updates our Nickel grammar, and adds support for let blocks.
- [#769](https://github.com/tweag/topiary/pull/769) Move the web playground to a separate branch
Expand Down
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,8 @@ opt-level = 3

[profile.release.package.lalrpop]
opt-level = 3

[workspace.metadata.typos]
files.extend-exclude = [
"/topiary-cli/tests/samples",
]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ Note: `fmt` is a recognised alias of the `format` subcommand.
`topiary visualise` converts the input's Tree-sitter parse tree to a graph
representation in the selected format. By default, Topiary outputs a DOT file,
which can be rendered using a visualisation tool such as the Graphviz suite. For
example, using Graphviz's `dot`: `topiary visualise input.ocaml | dot -Tpng
-ooutput.png`.
example, using Graphviz's `dot`: `topiary visualise input.ocaml | dot -T png
-o output.png`.

<!-- DO NOT REMOVE THE "usage" COMMENTS -->
<!-- usage:start:visualise -->
Expand Down
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ let
cargoArtifacts = craneLib.buildDepsOnly commonArgs;

# NB: we don't need to overlay our custom toolchain for the *entire*
# pkgs (which would require rebuidling anything else which uses rust).
# pkgs (which would require rebuilding anything else which uses rust).
# Instead, we just want to update the scope that crane will use by appending
# our specific toolchain there.
craneLibWasm = craneLib.overrideToolchain rustWithWasmTarget;
Expand Down
2 changes: 1 addition & 1 deletion topiary-cli/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ impl OutputFile {
impl fmt::Display for OutputFile {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Stdout => write!(f, "standard ouput"),
Self::Stdout => write!(f, "standard output"),
Self::Disk { output, .. } => write!(f, "{}", output.to_string_lossy()),
}
}
Expand Down
8 changes: 4 additions & 4 deletions topiary-cli/tests/samples/expected/nickel.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@
intermediate results resulting in less memory consumption and overall
better performance (outside of pathological cases).
`fold_left` also iterates from the start of the array, which
correponds to the usual behavior of loops and iterators in most
corresponds to the usual behavior of loops and iterators in most
programming languages. There is one case where `fold_right` might be
preferred, see the next point.
- If the folded function is associative but _(left) short-circuiting_,
Expand Down Expand Up @@ -1428,7 +1428,7 @@
error value.

The setters (`with_XXX` functions) always operate on the current error
diagnostic, which is the last diagnotic on the stack. If the stack is
diagnostic, which is the last diagnostic on the stack. If the stack is
empty, a fresh diagnostic is silently created when using a setter.

The previous diagnostics on the stack are considered archived, and
Expand Down Expand Up @@ -1736,7 +1736,7 @@

**Important** `any_of` is only an approximation of what you could
expect from an `or` operation on contracts. Because `any_of` must
preserve the lazyness of contracts, it means that it has to
preserve the laziness of contracts, it means that it has to
pick the right branch by relying only on the immediate part of each
contract, and not on the delayed part.

Expand Down Expand Up @@ -4063,7 +4063,7 @@
Asserts that all the elements of an array are equal to true. Applies the
`std.test.Assert` contract on each element of the given array.

Evalutes to `true` if all the elements of the array are equal to true,
Evaluates to `true` if all the elements of the array are equal to true,
or fails with a contract error otherwise.

# Example
Expand Down
2 changes: 1 addition & 1 deletion topiary-cli/tests/samples/expected/ocaml-interface.mli
Original file line number Diff line number Diff line change
Expand Up @@ -3183,7 +3183,7 @@ module Dal_errors : sig
commitment: Dal.Slot.Commitment.t;
commitment_proof: Dal.Slot.Commitment_proof.t;
}
| Dal_data_availibility_attestor_not_in_committee of
| Dal_data_availability_attestor_not_in_committee of
{
attestor: Signature.Public_key_hash.t;
level: Level.t;
Expand Down
2 changes: 1 addition & 1 deletion topiary-cli/tests/samples/expected/tree_sitter_query.scm
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@
; For those queries, we should not have multiple queries,
; however, due to a known bug in tree-sitter queries
; https://github.com/tree-sitter/tree-sitter/issues/1811
; using an alternative after the starred parenthesis does not work as intented.
; using an alternative after the starred parenthesis does not work as intended.
;
(
"("* @do_nothing
Expand Down
8 changes: 4 additions & 4 deletions topiary-cli/tests/samples/input/nickel.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ foo
intermediate results resulting in less memory consumption and overall
better performance (outside of pathological cases).
`fold_left` also iterates from the start of the array, which
correponds to the usual behavior of loops and iterators in most
corresponds to the usual behavior of loops and iterators in most
programming languages. There is one case where `fold_right` might be
preferred, see the next point.
- If the folded function is associative but _(left) short-circuiting_,
Expand Down Expand Up @@ -1438,7 +1438,7 @@ foo
error value.

The setters (`with_XXX` functions) always operate on the current error
diagnostic, which is the last diagnotic on the stack. If the stack is
diagnostic, which is the last diagnostic on the stack. If the stack is
empty, a fresh diagnostic is silently created when using a setter.

The previous diagnostics on the stack are considered archived, and
Expand Down Expand Up @@ -1746,7 +1746,7 @@ foo

**Important** `any_of` is only an approximation of what you could
expect from an `or` operation on contracts. Because `any_of` must
preserve the lazyness of contracts, it means that it has to
preserve the laziness of contracts, it means that it has to
pick the right branch by relying only on the immediate part of each
contract, and not on the delayed part.

Expand Down Expand Up @@ -4121,7 +4121,7 @@ foo
Asserts that all the elements of an array are equal to true. Applies the
`std.test.Assert` contract on each element of the given array.

Evalutes to `true` if all the elements of the array are equal to true,
Evaluates to `true` if all the elements of the array are equal to true,
or fails with a contract error otherwise.

# Example
Expand Down
2 changes: 1 addition & 1 deletion topiary-cli/tests/samples/input/ocaml-interface.mli
Original file line number Diff line number Diff line change
Expand Up @@ -3155,7 +3155,7 @@ module Dal_errors : sig
commitment : Dal.Slot.Commitment.t;
commitment_proof : Dal.Slot.Commitment_proof.t;
}
| Dal_data_availibility_attestor_not_in_committee of {
| Dal_data_availability_attestor_not_in_committee of {
attestor : Signature.Public_key_hash.t;
level : Level.t;
}
Expand Down
2 changes: 1 addition & 1 deletion topiary-cli/tests/samples/input/tree_sitter_query.scm
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@
; For those queries, we should not have multiple queries,
; however, due to a known bug in tree-sitter queries
; https://github.com/tree-sitter/tree-sitter/issues/1811
; using an alternative after the starred parenthesis does not work as intented.
; using an alternative after the starred parenthesis does not work as intended.
;
(
"("* @do_nothing
Expand Down
4 changes: 2 additions & 2 deletions topiary-config/src/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ impl GitSource {
Some(subdir) => tmp_dir.join(subdir),
None => tmp_dir,
}
// parser.c and potenial scanners are always in src/
// parser.c and potential scanners are always in src/
.join("src");

self.build_tree_sitter_library(name, &path, library_path)
Expand Down Expand Up @@ -345,7 +345,7 @@ impl GitSource {
)));
}

log::info!("{}: succesfully compiled", name);
log::info!("{}: successfully compiled", name);
Ok(())
}
}
4 changes: 2 additions & 2 deletions topiary-config/src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ impl Source {
// We always include the built-in configuration, as a fallback
let mut res: Vec<Self> = vec![Self::Builtin];

for candiate in candidates {
if let Some(path) = Self::find(&candiate) {
for candidate in candidates {
if let Some(path) = Self::find(&candidate) {
res.push(Self::File(path));
}
}
Expand Down
14 changes: 7 additions & 7 deletions topiary-core/src/atom_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub struct AtomCollection {

impl AtomCollection {
/// Returns a basic AtomCollection with the supplied atoms. Only used for
/// testing. Normally you should use `AtomCollection::collect_leafs`
/// testing. Normally you should use `AtomCollection::collect_leaves`
/// instead.
#[cfg(test)]
pub fn new(atoms: Vec<Atom>) -> Self {
Expand All @@ -83,7 +83,7 @@ impl AtomCollection {
}

/// Use this to create an initial `AtomCollection`
pub fn collect_leafs(
pub fn collect_leaves(
root: &Node,
source: &[u8],
specified_leaf_nodes: HashSet<usize>,
Expand All @@ -109,7 +109,7 @@ impl AtomCollection {
counter: 0,
};

atoms.collect_leafs_inner(root, source, &Vec::new(), 0)?;
atoms.collect_leaves_inner(root, source, &Vec::new(), 0)?;

Ok(atoms)
}
Expand Down Expand Up @@ -271,7 +271,7 @@ impl AtomCollection {
"prepend_spaced_softline" => {
self.prepend(Atom::Softline { spaced: true }, node, predicates);
}
// Skip over leafs
// Skip over leaves
"leaf" => {}
// Deletion
"delete" => {
Expand Down Expand Up @@ -505,7 +505,7 @@ impl AtomCollection {
/// # Errors
///
/// This function returns an error if it fails to convert the source code belonging to the node to UTF-8.
fn collect_leafs_inner(
fn collect_leaves_inner(
&mut self,
node: &Node,
source: &[u8],
Expand All @@ -526,7 +526,7 @@ impl AtomCollection {
log::debug!("Skipping zero-byte node: {}", node.display_one_based());
} else if node.child_count() == 0
|| self.specified_leaf_nodes.contains(&node.id())
// We treat error nodes as leafs when `tolerate_parsing_errors` is set to true.
// We treat error nodes as leaves when `tolerate_parsing_errors` is set to true.
// This ensures Topiary does not try to further apply transformations on them.
// If `tolerate_parsing_errors` is set to false, this part of the code is only reached if the tree contains no ERROR nodes,
// and as such the check below would be redundant.
Expand All @@ -543,7 +543,7 @@ impl AtomCollection {
self.mark_leaf_parent(node, node.id());
} else {
for child in node.children(&mut node.walk()) {
self.collect_leafs_inner(&child, source, &parent_ids, level + 1)?;
self.collect_leaves_inner(&child, source, &parent_ids, level + 1)?;
}
}

Expand Down
2 changes: 1 addition & 1 deletion topiary-core/src/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct Language {
/// the Configuration, and to convert from a language to the respective tree-sitter
/// grammar.
pub name: String,
/// The Query Topiary will use to get the formating captures, must be
/// The Query Topiary will use to get the formatting captures, must be
/// present. The topiary engine does not include any formatting queries.
pub query: TopiaryQuery,
/// The tree-sitter Language. Topiary will use this Language for parsing.
Expand Down
2 changes: 1 addition & 1 deletion topiary-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ pub enum Operation {
},
/// Visualises the parsed file's tree-sitter tree
Visualise {
/// Choose the type of visualation Topiary should ouput
/// Choose the type of visualation Topiary should output
output_format: Visualisation,
},
}
Expand Down
2 changes: 1 addition & 1 deletion topiary-core/src/pretty.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! After being split into Atoms, and the queries having been applied this
//! module is reponsible for rendering the slice of Atoms back into a displayable
//! module is responsible for rendering the slice of Atoms back into a displayable
//! format.

use std::fmt::Write;
Expand Down
6 changes: 3 additions & 3 deletions topiary-core/src/tree_sitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Display for Position {
}

/// Topiary often needs both the tree-sitter `Query` and the original content
/// beloging to the file from which the query was parsed. This struct is a simple
/// belonging to the file from which the query was parsed. This struct is a simple
/// convenience wrapper that combines the `Query` with its original string.
#[derive(Debug)]
pub struct TopiaryQuery {
Expand Down Expand Up @@ -254,11 +254,11 @@ pub fn apply_query(
}

// Find the ids of all tree-sitter nodes that were identified as a leaf
// We want to avoid recursing into them in the collect_leafs function.
// We want to avoid recursing into them in the collect_leaves function.
let specified_leaf_nodes: HashSet<usize> = collect_leaf_ids(&matches, capture_names.clone());

// The Flattening: collects all terminal nodes of the tree-sitter tree in a Vec
let mut atoms = AtomCollection::collect_leafs(&root, source, specified_leaf_nodes)?;
let mut atoms = AtomCollection::collect_leaves(&root, source, specified_leaf_nodes)?;

log::debug!("List of atoms before formatting: {atoms:?}");

Expand Down
8 changes: 4 additions & 4 deletions topiary-queries/queries/nickel.scm
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@

; Start a new scope for annotations, used to properly indent any content coming
; after the annotations. We use Topiary's measuring scope feature: the
; multi-liness of this scope is entirely decided by the annotations only, but
; multi-lineness of this scope is entirely decided by the annotations only, but
; what we want to affect is larger, namely the content of the binding coming
; after the `=`.
(
Expand Down Expand Up @@ -429,7 +429,7 @@
; Indent the bound expression of a let-binding (or a field definition) in
; presence of multi-line annotations. That's where we use the measuring scope of
; "annotations_with_content": we want this rule to fire only when (annot) is
; multi-line, regardless of the multi-liness of the ("=" (term)) part.
; multi-line, regardless of the multi-lineness of the ("=" (term)) part.
(_
(#multi_line_scope_only! "annotations_with_content")
(annot) @append_indent_start
Expand Down Expand Up @@ -471,7 +471,7 @@
; In the case of unary applications, we always lay out the function application
; on one line (the argument might still span multiple lines, but the separation
; between the function and the operand is a space), and we don't add
; indentation. Doing otherwise would often add unncessary indentation when the
; indentation. Doing otherwise would often add unnecessary indentation when the
; argument is e.g. a function, a record or an array literal, etc.

; The multi-line character of an application depends on both the function and
Expand All @@ -481,7 +481,7 @@
(applicative) @prepend_begin_scope
) @append_end_scope

; In the the mutli-ary application case, we add a softline before each argument,
; In the the multi-ary application case, we add a softline before each argument,
; and we indent it.
;
; Note that this pattern won't match the very last argument of an applicative
Expand Down
2 changes: 1 addition & 1 deletion topiary-queries/queries/ocamllex.scm
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
)

(lexer_case
; The anonymouse child of the lexer_case is the regexp
; The anonymous child of the lexer_case is the regexp
(_) @prepend_space @append_space
(action) @prepend_space @prepend_indent_start @append_indent_end
)
2 changes: 1 addition & 1 deletion web-playground/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function App() {
Check idempotence (formatting twice is the same as formatting once)
</label>
<label>
<input type="checkbox" id="tolerateParsingErros" checked={tolerateParsingErrors} onChange={handleTolerateParsingErrors} />
<input type="checkbox" id="tolerateParsingErrors" checked={tolerateParsingErrors} onChange={handleTolerateParsingErrors} />
Tolerate parsing errors
</label>
</div>
Expand Down
Loading