Skip to content

Commit

Permalink
fix: address stylistic comments from PR (stjude-rust-labs#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
thatRichman committed Dec 12, 2024
1 parent 058eff3 commit 540368f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ parking_lot = "0.12.3"
path-clean = "1.0.1"
petgraph = "0.6.5"
pretty_assertions = "1.4.0"
rand = "0.8.5"
rayon = "1.10.0"
regex = "1.11.1"
reqwest = { version = "0.12.5", default-features = false, features = ["rustls-tls", "http2", "charset"] }
Expand Down
5 changes: 3 additions & 2 deletions wdl-lint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ readme = "../README.md"

[dependencies]
wdl-ast = { path = "../wdl-ast", version = "0.9.0" }
anyhow = { workspace = true }
convert_case = { workspace = true }
indexmap = { workspace = true }
rand = { workspace = true }
rowan = { workspace = true }
serde_json = { workspace = true }
anyhow = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }

[dev-dependencies]
codespan-reporting = { workspace = true }
Expand Down
18 changes: 9 additions & 9 deletions wdl-lint/src/rules/shellcheck.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! A lint rule for checking mixed indentation in command text.
//! A lint rule for running shellcheck against command sections.
use std::collections::HashMap;
use std::collections::HashSet;
use std::io::Write;
Expand Down Expand Up @@ -63,7 +63,7 @@ const ID: &str = "CommandSectionShellCheck";
///
/// The file and fix fields are ommitted as we have no use for them.
#[derive(Clone, Debug, Deserialize)]
struct ShellCheckComment {
struct ShellCheckDiagnostic {
/// line number comment starts on
pub line: usize,
/// line number comment ends on
Expand All @@ -82,11 +82,11 @@ struct ShellCheckComment {
pub message: String,
}

/// Run shellcheck
/// Run shellcheck on a command.
///
/// writes command text to stdin of shellcheck process
/// and returns parsed ShellCheckComments
fn run_shellcheck(command: &str) -> Result<Vec<ShellCheckComment>> {
/// and returns parsed `ShellCheckDiagnostic`s
fn run_shellcheck(command: &str) -> Result<Vec<ShellCheckDiagnostic>> {
let mut sc_proc = process::Command::new(SHELLCHECK_BIN)
.args([
"-s",
Expand Down Expand Up @@ -117,7 +117,7 @@ fn run_shellcheck(command: &str) -> Result<Vec<ShellCheckComment>> {
// any checked files result in comments
// so cannot check with status.success()
match output.status.code() {
Some(0) | Some(1) => serde_json::from_slice::<Vec<ShellCheckComment>>(&output.stdout)
Some(0) | Some(1) => serde_json::from_slice::<Vec<ShellCheckDiagnostic>>(&output.stdout)
.context("deserializing STDOUT from `shellcheck` process"),
Some(code) => bail!("unexpected `shellcheck` exit code: {}", code),
None => bail!("the `shellcheck` process appears to have been interrupted"),
Expand All @@ -138,10 +138,10 @@ impl Rule for ShellCheckRule {
}

fn explanation(&self) -> &'static str {
"ShellCheck is a static analysis tool and linter for sh / bash. \
"ShellCheck (https://shellcheck.net) is a static analysis tool and linter for sh / bash. \
The lints provided by ShellCheck help prevent common errors and \
pitfalls in your scripts. Following its recommendations will increase \
the robustness of your command blocks."
the robustness of your command sections."
}

fn tags(&self) -> TagSet {
Expand Down Expand Up @@ -370,7 +370,7 @@ impl Visitor for ShellCheckRule {
let command_keyword = support::token(section.syntax(), SyntaxKind::CommandKeyword)
.expect("should have a command keyword token");
state.exceptable_add(
Diagnostic::error("running `shellcheck` on command block")
Diagnostic::error("running `shellcheck` on command section")
.with_label(e.to_string(), command_keyword.text_range().to_span())
.with_rule(ID)
.with_fix("address reported error."),
Expand Down

0 comments on commit 540368f

Please sign in to comment.