Skip to content

Commit

Permalink
ci: fixing typos programmatically (#5975)
Browse files Browse the repository at this point in the history
## Description

Adds a CI check for typos and fixes all* typos in code, comments, and
docs.

*found by [typos-cli](https://github.com/crate-ci/typos)

`typos` doesn't catch everything, but it seems to work better than
codespell and cargo-spellcheck (fewer false positives).

## Checklist

- [ ] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [ ] I have requested a review from the relevant team or maintainers.
  • Loading branch information
sdankel authored May 9, 2024
1 parent 4a63b41 commit f8e8d35
Show file tree
Hide file tree
Showing 79 changed files with 139 additions and 114 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/spellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Spellcheck

on:
pull_request:

jobs:
find-typos:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Check spelling
uses: crate-ci/typos@master
with:
config: .typos.toml
9 changes: 9 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[default]
extend-ignore-identifiers-re = [
"var*",
"ba",
"TRO",
"tro",
"Tro",
"Nam",
]
16 changes: 8 additions & 8 deletions benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ forc_path="$SCRIPT_DIR/target/$build_type/forc"

# prepare the benchmark data for commit if requested
if $PREPARE_FOR_COMMIT; then
sway_peformance_data_dir=performance-data
sway_performance_data_dir=performance-data
[email protected]:FuelLabs/sway-performance-data.git

if [ ! -d "$SCRIPT_DIR/$sway_peformance_data_dir" ]; then
echo "Directory $sway_peformance_data_dir not found. Cloning the repository..."
git clone "$sway_performance_data_repo_url" "$sway_peformance_data_dir"
echo "Repository cloned into $sway_peformance_data_dir."
if [ ! -d "$SCRIPT_DIR/$sway_performance_data_dir" ]; then
echo "Directory $sway_performance_data_dir not found. Cloning the repository..."
git clone "$sway_performance_data_repo_url" "$sway_performance_data_dir"
echo "Repository cloned into $sway_performance_data_dir."
else
echo "Updating sway-performance-data repository..."
git -C "$SCRIPT_DIR/$sway_peformance_data_dir" pull
git -C "$SCRIPT_DIR/$sway_performance_data_dir" pull
fi

mkdir -p "$SCRIPT_DIR/$sway_peformance_data_dir/$GITHUB_SHA"
cp -r $benchmarks_dir/* "$SCRIPT_DIR/$sway_peformance_data_dir/$GITHUB_SHA"
mkdir -p "$SCRIPT_DIR/$sway_performance_data_dir/$GITHUB_SHA"
cp -r $benchmarks_dir/* "$SCRIPT_DIR/$sway_performance_data_dir/$GITHUB_SHA"
else
sway_libs_dir=sway-libs
sway_libs_repo_url=https://github.com/FuelLabs/sway-libs.git
Expand Down
2 changes: 1 addition & 1 deletion docs/internals.md
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ The optimization passes are organized as different pass groups inside a [`PassMa
pass_group.append_pass(RETDEMOTION_NAME);
pass_group.append_pass(MISCDEMOTION_NAME);

// Convert loads and stores to mem_copys where possible.
// Convert loads and stores to mem_copies where possible.
pass_group.append_pass(MEMCPYOPT_NAME);

// Run a DCE and simplify-cfg to clean up any obsolete instructions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl Owner {

enum Role {
FullAccess: (),
PartialAcess: (),
PartialAccess: (),
NoAccess: (),
}
// ANCHOR_END: data_structures
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ If the condition evaluates to the [Boolean](../built-ins/boolean.md) value of `t

On the other hand if the condition evaluates to `false` then we check the next condition, in this case if the `number` is divisible by `4`. We can have as many `else if` checks as we like as long as they evaluate to a Boolean.

At the end there is a special case which is known as a `catch all` case i.e. the `else`. What this means is that we have gone through all of our conditional checks above and none of them have been met. In this scenario we may want to have some special logic to handle a generic case which encompases all the other conditions which we do not care about or can be treated in the same way.
At the end there is a special case which is known as a `catch all` case i.e. the `else`. What this means is that we have gone through all of our conditional checks above and none of them have been met. In this scenario we may want to have some special logic to handle a generic case which encompasses all the other conditions which we do not care about or can be treated in the same way.

## Using if & let together

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ There are two functions that can be used to mint:
- [`mint()`](./mint.md)
- [`mint_to()`](./address-or-contract.md)

Specific implementation details on transfering assets to addresses can be found [here](./address.md).
Specific implementation details on transferring assets to addresses can be found [here](./address.md).

Specific implementation details on transfering assets to contracts can be found [here](./contract.md).
Specific implementation details on transferring assets to contracts can be found [here](./contract.md).
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ There is one function that can be used to transfer an asset to any entity:

- [`transfer()`](./address-or-contract.md)

Specific implementation details on transfering assets to addresses can be found [here](./address.md).
Specific implementation details on transferring assets to addresses can be found [here](./address.md).

Specific implementation details on transfering assets to contracts can be found [here](./contract.md).
Specific implementation details on transferring assets to contracts can be found [here](./contract.md).
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ We'll begin by defining the `Owner` & `Role` data structures and implement a `de
{{#include ../../../code/operations/storage/storage_init/src/main.sw:data_structures}}
```

Now that we have our data structures we'll keep track of how many `current_owners` we have and declare the owner in the two aformentioned styles.
Now that we have our data structures we'll keep track of how many `current_owners` we have and declare the owner in the two aforementioned styles.

```sway
{{#include ../../../code/operations/storage/storage_init/src/main.sw:initialization}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# StorageVec

A `StorageVec` is a vector that permanently stores its data in `storage`. It replicates the functionality of a regular vector however its data is not stored contigiously because it utilizes hashing and [generics](../../../language/generics/index.md) to find a location to store the value `T`.
A `StorageVec` is a vector that permanently stores its data in `storage`. It replicates the functionality of a regular vector however its data is not stored contiguously because it utilizes hashing and [generics](../../../language/generics/index.md) to find a location to store the value `T`.

There is a number of methods in the [standard library](https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/storage.sw) however we will take a look at pushing and retrieving data.

Expand Down
2 changes: 1 addition & 1 deletion examples/tuples/src/main.sw
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
library;

fn tuple() {
// You can declare the types youself
// You can declare the types yourself
let tuple1: (u8, bool, u64) = (100, false, 10000);

// Or have the types be inferred
Expand Down
10 changes: 5 additions & 5 deletions forc-pkg/src/manifest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ impl PackageManifestFile {
pkg_dir.pop();
if let Some(nested_package) = find_nested_manifest_dir(&pkg_dir) {
// remove file name from nested_package_manifest
bail!("Nested packages are not supported, please consider seperating the nested package at {} from the package at {}, or if it makes sense consider creating a workspace.", nested_package.display(), pkg_dir.display())
bail!("Nested packages are not supported, please consider separating the nested package at {} from the package at {}, or if it makes sense consider creating a workspace.", nested_package.display(), pkg_dir.display())
}
Ok(())
}
Expand Down Expand Up @@ -875,7 +875,7 @@ impl GenericManifestFile for WorkspaceManifestFile {
// package manifest as a workspace manifest), look into the parent directories for a
// legitimate workspace manifest. If the error returned is something else this is a
// workspace manifest with errors, classify this as a workspace manifest but with
// errors so that the erros will be displayed to the user.
// errors so that the errors will be displayed to the user.
Self::from_file(possible_path)
.err()
.map(|e| !e.to_string().contains("missing field `workspace`"))
Expand Down Expand Up @@ -956,7 +956,7 @@ impl WorkspaceManifest {
}

// Check for duplicate pkg name entries in member manifests of this workspace.
let duplciate_pkg_lines = pkg_name_to_paths
let duplicate_pkg_lines = pkg_name_to_paths
.iter()
.filter_map(|(pkg_name, paths)| {
if paths.len() > 1 {
Expand All @@ -970,8 +970,8 @@ impl WorkspaceManifest {
})
.collect::<Vec<_>>();

if !duplciate_pkg_lines.is_empty() {
let error_message = duplciate_pkg_lines.join("\n");
if !duplicate_pkg_lines.is_empty() {
let error_message = duplicate_pkg_lines.join("\n");
bail!(
"Duplicate package names detected in the workspace:\n\n{}",
error_message
Expand Down
8 changes: 4 additions & 4 deletions forc-pkg/src/pkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ impl MemberFilter {
let pkg = &graph[node_ix];
let pkg_manifest = &manifest_map[&pkg.id()];
let program_type = pkg_manifest.program_type();
// Since parser cannot recover for program type detection, for the scenerios that
// Since parser cannot recover for program type detection, for the scenarios that
// parser fails to parse the code, program type detection is not possible. So in
// failing to parse cases we should try to build at least until
// https://github.com/FuelLabs/sway/issues/3017 is fixed. Until then we should
Expand Down Expand Up @@ -1012,7 +1012,7 @@ fn validate_dep(

Ok(dep_manifest)
}
/// Part of dependency validation, any checks related to the depenency's manifest content.
/// Part of dependency validation, any checks related to the dependency's manifest content.
fn validate_dep_manifest(
dep: &Pinned,
dep_manifest: &PackageManifestFile,
Expand Down Expand Up @@ -1242,7 +1242,7 @@ fn graph_to_manifest_map(manifests: &MemberManifestFiles, graph: &Graph) -> Resu
/// Assumes the given `graph` only contains valid dependencies (see `validate_graph`).
///
/// `pkg_graph_to_manifest_map` starts from each node (which corresponds to the given proj_manifest)
/// and visits childs to collect their manifest files.
/// and visits children to collect their manifest files.
fn pkg_graph_to_manifest_map(
manifests: &MemberManifestFiles,
pkg_name: &str,
Expand Down Expand Up @@ -2325,7 +2325,7 @@ pub fn build(

let is_contract_dependency = is_contract_dependency(plan.graph(), node);
// If we are building a contract and tests are enabled or we are building a contract
// dependency, we need the tests exlcuded bytecode.
// dependency, we need the tests excluded bytecode.
let bytecode_without_tests = if (include_tests
&& matches!(manifest.program_type(), Ok(TreeType::Contract)))
|| is_contract_dependency
Expand Down
2 changes: 1 addition & 1 deletion forc-pkg/src/source/git/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub(crate) struct AuthHandler {

impl AuthHandler {
/// Creates a new `AuthHandler` from all fields of the struct. If there are no specific reasons
/// not to, `default_with_config` should be prefered.
/// not to, `default_with_config` should be preferred.
fn new(
config: git2::Config,
ssh_authentication_attempt: bool,
Expand Down
6 changes: 3 additions & 3 deletions forc-pkg/src/source/git/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const DEFAULT_REMOTE_NAME: &str = "origin";

/// Everything needed to recognize a checkout in offline mode
///
/// Since we are omiting `.git` folder to save disk space, we need an indexing file
/// Since we are omitting `.git` folder to save disk space, we need an indexing file
/// to recognize a checkout while searching local checkouts in offline mode
#[derive(Serialize, Deserialize)]
pub struct SourceIndex {
Expand Down Expand Up @@ -377,7 +377,7 @@ fn tmp_git_repo_dir(fetch_id: u64, name: &str, repo: &Url) -> PathBuf {
git_checkouts_directory().join("tmp").join(repo_dir_name)
}

/// Given a git reference, build a list of `refspecs` required for the fetch opration.
/// Given a git reference, build a list of `refspecs` required for the fetch operation.
///
/// Also returns whether or not our reference implies we require fetching tags.
fn git_ref_to_refspecs(reference: &Reference) -> (Vec<String>, bool) {
Expand Down Expand Up @@ -508,7 +508,7 @@ pub fn commit_path(name: &str, repo: &Url, commit_hash: &str) -> PathBuf {
///
/// Returns the location of the checked out commit.
///
/// NOTE: This function assumes that the caller has aquired an advisory lock to co-ordinate access
/// NOTE: This function assumes that the caller has acquired an advisory lock to co-ordinate access
/// to the git repository checkout path.
pub fn fetch(fetch_id: u64, name: &str, pinned: &Pinned) -> Result<PathBuf> {
let path = commit_path(name, &pinned.source.repo, &pinned.commit_hash);
Expand Down
2 changes: 1 addition & 1 deletion forc-pkg/src/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ impl Pinned {

/// If the source is associated with a specific semver version, emit it.
///
/// Used soley for the package lock file.
/// Used solely for the package lock file.
pub fn semver(&self) -> Option<semver::Version> {
match self {
Self::Registry(reg) => Some(reg.source.version.clone()),
Expand Down
4 changes: 2 additions & 2 deletions forc-plugins/forc-client/src/cmd/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub struct Command {
#[clap(long)]
pub salt: Option<Vec<String>>,
/// Generate a default salt (0x0000000000000000000000000000000000000000000000000000000000000000) for the contract.
/// Useful for CI, to create reproducable deployments.
/// Useful for CI, to create reproducible deployments.
#[clap(long)]
pub default_salt: bool,
#[clap(flatten)]
Expand All @@ -64,7 +64,7 @@ pub struct Command {
///
/// By default, storage slots are initialized with the values defined in the storage block in
/// the contract. You can override the initialization by providing the file path to a JSON file
/// containing the overriden values.
/// containing the overridden values.
///
/// The file format and key values should match the compiler-generated `*-storage_slots.json` file in the output
/// directory of the compiled contract.
Expand Down
2 changes: 1 addition & 1 deletion forc-plugins/forc-doc/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ impl HTMLString {
}
}

/// The type of document. Helpful in detemining what to represent in
/// The type of document. Helpful in determining what to represent in
/// the sidebar & page content.
#[derive(Clone, Ord, PartialOrd, Eq, PartialEq)]
pub(crate) enum DocStyle {
Expand Down
2 changes: 1 addition & 1 deletion forc-plugins/forc-doc/src/render/util/format/docstring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub(crate) fn create_preview(raw_attributes: Option<String>) -> Option<String> {
}

/// Checks if some raw html (rendered from markdown) contains a header.
/// If it does, it splits at the header and returns the slice that preceeded it.
/// If it does, it splits at the header and returns the slice that preceded it.
pub(crate) fn split_at_markdown_header(raw_html: &str) -> &str {
for header in HTML_HEADERS {
if raw_html.contains(header) {
Expand Down
4 changes: 2 additions & 2 deletions forc-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub struct TestResult {
pub state: vm::state::ProgramState,
/// The required state of the VM for this test to pass.
pub condition: pkg::TestPassCondition,
/// Emitted `Recipt`s during the execution of the test.
/// Emitted `Receipt`s during the execution of the test.
pub logs: Vec<fuel_tx::Receipt>,
/// Gas used while executing this test.
pub gas_used: u64,
Expand Down Expand Up @@ -274,7 +274,7 @@ fn get_contract_dependency_map(
let pinned_member = graph[member_node].clone();
let contract_dependencies = build_plan
.contract_dependencies(member_node)
.map(|contract_depency_node_ix| graph[contract_depency_node_ix].clone())
.map(|contract_dependency_node_ix| graph[contract_dependency_node_ix].clone())
.filter_map(|pinned| built_members.get(&pinned))
.cloned()
.collect::<Vec<_>>();
Expand Down
2 changes: 1 addition & 1 deletion forc-util/src/fs_locking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ mod test {
#[test]
fn test_fs_locking_same_process() {
let x = PidFileLocking::lsp("test");
assert!(!x.is_locked()); // checks the non-existance of the lock (therefore it is not locked)
assert!(!x.is_locked()); // checks the non-existence of the lock (therefore it is not locked)
assert!(x.lock().is_ok());
// The current process is locking "test"
let x = PidFileLocking::lsp("test");
Expand Down
2 changes: 1 addition & 1 deletion sway-core/src/asm_lang/allocated_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ pub(crate) enum AllocatedOpcode {
AllocatedRegister,
),

/* Conrol Flow Instructions */
/* Control Flow Instructions */
JMP(AllocatedRegister),
JI(VirtualImmediate24),
JNE(AllocatedRegister, AllocatedRegister, AllocatedRegister),
Expand Down
2 changes: 1 addition & 1 deletion sway-core/src/asm_lang/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ impl Op {
}
}

/// Dymamically jumps to a register value.
/// Dynamically jumps to a register value.
pub(crate) fn jump_to_register(
reg: VirtualRegister,
comment: impl Into<String>,
Expand Down
4 changes: 2 additions & 2 deletions sway-core/src/control_flow_analysis/dead_code_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl<'cfg> ControlFlowGraph<'cfg> {
true
} else {
// Consider variables declarations alive when count is greater than 1
// This is explicilty required because the variable may be considered dead
// This is explicitly required because the variable may be considered dead
// when it is not connected from an entry point, while it may still be used by other dead code.
connections_count
.get(n)
Expand All @@ -182,7 +182,7 @@ impl<'cfg> ControlFlowGraph<'cfg> {
true
} else {
// Consider param alive when count is greater than 1
// This is explicilty required because the param may be considered dead
// This is explicitly required because the param may be considered dead
// when it is not connected from an entry point, while it may still be used by other dead code.
connections_count
.get(n)
Expand Down
2 changes: 1 addition & 1 deletion sway-core/src/ir_generation/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ pub(crate) fn compile_constants(
// c) ditto for enums.
//
// And for structs and enums in particular, we must ignore those with embedded generic types as
// they are monomorphised only at the instantation site. We must ignore the generic declarations
// they are monomorphised only at the instantiation site. We must ignore the generic declarations
// altogether anyway.
fn compile_declarations(
engines: &Engines,
Expand Down
2 changes: 1 addition & 1 deletion sway-core/src/language/ty/declaration/struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl TyStructDecl {
/// within the struct memory layout, or `None` if the field with the
/// name `field_name` does not exist.
pub(crate) fn get_field_index_and_type(&self, field_name: &Ident) -> Option<(u64, TypeId)> {
// TODO-MEMLAY: Warning! This implementation assumes that fields are layed out in
// TODO-MEMLAY: Warning! This implementation assumes that fields are laid out in
// memory in the order of their declaration.
// This assumption can be changed in the future.
self.fields
Expand Down
2 changes: 1 addition & 1 deletion sway-core/src/language/ty/expression/expression_variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ impl ReplaceDecls for TyExpressionVariant {

// Finds method implementation for method dummy and replaces it.
// This is required because dummy methods don't have type parameters from impl traits.
// Thus we use the implementated method that already contains all the required type parameters,
// Thus we use the implemented method that already contains all the required type parameters,
// including those from the impl trait.
if method.is_trait_method_dummy {
if let Some(implementing_for_typeid) = method.implementing_for_typeid {
Expand Down
2 changes: 1 addition & 1 deletion sway-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ pub(crate) fn compile_ast_to_ir_to_asm(
pass_group.append_pass(RETDEMOTION_NAME);
pass_group.append_pass(MISCDEMOTION_NAME);

// Convert loads and stores to mem_copys where possible.
// Convert loads and stores to mem_copies where possible.
pass_group.append_pass(MEMCPYOPT_NAME);

// Run a DCE and simplify-cfg to clean up any obsolete instructions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ where
let name = x.name.as_str();
Some(match &*engines.te().get(x.type_argument.type_id) {
// unit
TypeInfo::Tuple(fiels) if fiels.is_empty() => {
TypeInfo::Tuple(fields) if fields.is_empty() => {
format!("{} => {}::{}, \n", x.tag, enum_name, name)
},
_ => {
Expand Down
Loading

0 comments on commit f8e8d35

Please sign in to comment.