Skip to content

Commit

Permalink
chore: fix some comments
Browse files Browse the repository at this point in the history
Signed-off-by: cuishuang <[email protected]>
  • Loading branch information
cuishuang committed May 2, 2024
1 parent ec22cb6 commit de5fd6c
Show file tree
Hide file tree
Showing 18 changed files with 21 additions and 21 deletions.
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
2 changes: 1 addition & 1 deletion 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
2 changes: 1 addition & 1 deletion forc-pkg/src/pkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2343,7 +2343,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
4 changes: 2 additions & 2 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 @@ -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
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/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 sway-core/src/control_flow_analysis/dead_code_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,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 @@ -195,7 +195,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-lsp/src/capabilities/code_actions/diagnostic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use lsp_types::CodeActionOrCommand;
use self::auto_import::import_code_action;
use self::qualify::qualify_code_action;

/// Returns a list of [CodeActionOrCommand] based on the relavent compiler diagnostics.
/// Returns a list of [CodeActionOrCommand] based on the relevant compiler diagnostics.
pub(crate) fn code_actions(ctx: &CodeActionContext) -> Option<Vec<CodeActionOrCommand>> {
// Find diagnostics that have attached metadata.
let diagnostics_with_data = ctx.diagnostics.iter().filter_map(|diag| {
Expand Down
2 changes: 1 addition & 1 deletion sway-lsp/src/core/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl Token {
/// This type is used as the key in the [TokenMap]. It's constructed during AST traversal
/// where we compute the [Range] of the token and the convert [SourceId]'s to [PathBuf]'s.
/// Although this introduces a small amount of overhead while traversing, precomputing this
/// greatly speeds up performace in all other areas of the language server.
/// greatly speeds up performance in all other areas of the language server.
///
/// [TokenMap]: crate::core::token_map::TokenMap
/// [SourceId]: sway_types::SourceId
Expand Down
2 changes: 1 addition & 1 deletion sway-lsp/src/handlers/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ pub(crate) async fn handle_inlay_hints(
///
/// A formatted AST is written to a temporary file and the URI is
/// returned to the client so it can be opened and displayed in a
/// seperate side panel.
/// separate side panel.
pub async fn handle_show_ast(
state: &ServerState,
params: lsp_ext::ShowAstParams,
Expand Down
2 changes: 1 addition & 1 deletion swayfmt/src/items/item_abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl CurlyBrace for ItemAbi {
line: &mut String,
formatter: &mut Formatter,
) -> Result<(), FormatterError> {
// If shape is becoming left-most alligned or - indent just have the defualt shape
// If shape is becoming left-most alligned or - indent just have the default shape
formatter.unindent();
write!(
line,
Expand Down
2 changes: 1 addition & 1 deletion swayfmt/src/items/item_enum/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl CurlyBrace for ItemEnum {
line: &mut String,
formatter: &mut Formatter,
) -> Result<(), FormatterError> {
// If shape is becoming left-most aligned or - indent just have the defualt shape
// If shape is becoming left-most aligned or - indent just have the default shape
formatter.unindent();
write!(
line,
Expand Down
2 changes: 1 addition & 1 deletion swayfmt/src/items/item_fn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl CurlyBrace for ItemFn {
line: &mut FormattedCode,
formatter: &mut Formatter,
) -> Result<(), FormatterError> {
// If shape is becoming left-most alligned or - indent just have the defualt shape
// If shape is becoming left-most alligned or - indent just have the default shape
formatter.unindent();
write!(
line,
Expand Down
2 changes: 1 addition & 1 deletion swayfmt/src/items/item_struct/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl CurlyBrace for ItemStruct {
line: &mut String,
formatter: &mut Formatter,
) -> Result<(), FormatterError> {
// If shape is becoming left-most alligned or - indent just have the defualt shape
// If shape is becoming left-most alligned or - indent just have the default shape
formatter.unindent();
write!(
line,
Expand Down
2 changes: 1 addition & 1 deletion swayfmt/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Based on `rustfmt`, `swayfmt` aims to be a transparent approach to formatting Sway code.
//!
//! `swayfmt` configurations can be adjusted with a `swayfmt.toml` config file declared at the root of a Sway project,
//! however the defualt formatter does not require the presence of one and any fields omitted will remain as default.
//! however the default formatter does not require the presence of one and any fields omitted will remain as default.

#![allow(dead_code)]
pub mod comments;
Expand Down
2 changes: 1 addition & 1 deletion swayfmt/src/utils/map/newline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ fn add_newlines(
// Since we are adding newline sequences into the formatted code, in the next iteration the spans we find for the formatted code needs to be offsetted
// as the total length of newline sequences we added in previous iterations.
let mut offset = 0;
// We will definetly have a span in the collected span since for a source code to be parsed there should be some tokens present.
// We will definitely have a span in the collected span since for a source code to be parsed there should be some tokens present.
let mut previous_unformatted_newline_span = unformatted_newline_spans
.first()
.ok_or(FormatterError::NewlineSequenceError)?;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
category = "fail"

# check: $()Nested packages are not supported, please consider seperating the nested package at
# check: $()Nested packages are not supported, please consider separating the nested package at
# check: $() from the package at
# check: $(), or if it makes sense consider creating a workspace.

0 comments on commit de5fd6c

Please sign in to comment.