Skip to content

Commit 16381e8

Browse files
a-frantzadthrasher
andauthored
feat: body matches definition in #12 (#62)
Co-authored-by: Andrew Thrasher <[email protected]>
1 parent 6388cca commit 16381e8

18 files changed

+169
-75
lines changed

RULES.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This table documents all implemented `wdl` rules (validation failures and lint
44
warnings) implemented on the `main` branch of the `stjude-rust-labs/wdl`
55
repository. Note that the information may be out of sync with released packages.
66

7-
# Validation Failures
7+
## Validation Failures
88

99
| Name | Code | Package |
1010
|:---------------------------|:-----------|:----------------------------------------|
@@ -13,23 +13,23 @@ repository. Note that the information may be out of sync with released packages.
1313
| `duplicate_runtime_keys` | `v1::E003` | [`wdl-grammar`][wdl-grammar-validation] |
1414
| `missing_literal_commas` | `v1::E004` | [`wdl-grammar`][wdl-grammar-validation] |
1515

16-
# Lint Warnings
16+
## Lint Warnings
1717

18-
| Name | Code | Group | Package |
19-
|:--------------------------|:-----------|:-------------|:-----------------------------------|
20-
| `whitespace` | `v1::W001` | Style | [`wdl-grammar`][wdl-grammar-lints] |
21-
| `no_curly_commands` | `v1::W002` | Pedantic | [`wdl-grammar`][wdl-grammar-lints] |
22-
| `matching_parameter_meta` | `v1::W003` | Completeness | [`wdl-ast`][wdl-ast-lints] |
23-
| `mixed_indentation` | `v1::W004` | Style | [`wdl-grammar`][wdl-grammar-lints] |
24-
| `missing_runtime_block` | `v1::W005` | Completeness | [`wdl-grammar`][wdl-grammar-lints] |
25-
| `snake_case` | `v1::W006` | Naming | [`wdl-grammar`][wdl-grammar-lints] |
26-
| `newline_eof` | `v1::W007` | Spacing | [`wdl-grammar`][wdl-grammar-lints] |
27-
| `document_preamble` | `v1::W009` | Spacing | [`wdl-grammar`][wdl-grammar-lints] |
28-
| `preamble_comment` | `v1::W010` | Style | [`wdl-grammar`][wdl-grammar-lints] |
29-
| `one_empty_line` | `v1::W011` | Spacing | [`wdl-grammar`][wdl-grammar-lints] |
30-
| `double_quotes` | `v1::W012` | Naming | [`wdl-grammar`][wdl-grammar-lints] |
18+
| Name | Code | Tags | Package |
19+
|:--------------------------|:-----------|:--------------------------|:-----------------------------------|
20+
| `whitespace` | `v1::W001` | Spacing, Style | [`wdl-grammar`][wdl-grammar-lints] |
21+
| `no_curly_commands` | `v1::W002` | Clarity | [`wdl-grammar`][wdl-grammar-lints] |
22+
| `matching_parameter_meta` | `v1::W003` | Completeness | [`wdl-ast`][wdl-ast-lints] |
23+
| `mixed_indentation` | `v1::W004` | Spacing, Style, Clarity | [`wdl-grammar`][wdl-grammar-lints] |
24+
| `missing_runtime_block` | `v1::W005` | Completeness, Portability | [`wdl-grammar`][wdl-grammar-lints] |
25+
| `snake_case` | `v1::W006` | Naming, Style, Clarity | [`wdl-grammar`][wdl-grammar-lints] |
26+
| `newline_eof` | `v1::W007` | Spacing, Style | [`wdl-grammar`][wdl-grammar-lints] |
27+
| `document_preamble` | `v1::W009` | Spacing, Style | [`wdl-grammar`][wdl-grammar-lints] |
28+
| `preamble_comment` | `v1::W010` | Style | [`wdl-grammar`][wdl-grammar-lints] |
29+
| `one_empty_line` | `v1::W011` | Spacing, Style | [`wdl-grammar`][wdl-grammar-lints] |
30+
| `double_quotes` | `v1::W012` | Style, Clarity | [`wdl-grammar`][wdl-grammar-lints] |
3131

3232
[wdl-ast-lints]: https://docs.rs/wdl-ast/latest/wdl_ast/v1/index.html#lint-rules
3333
[wdl-ast-validation]: https://docs.rs/wdl-ast/latest/wdl_ast/v1/index.html#validation-rules
3434
[wdl-grammar-lints]: https://docs.rs/wdl-grammar/latest/wdl_grammar/v1/index.html#lint-rules
35-
[wdl-grammar-validation]: https://docs.rs/wdl-grammar/latest/wdl_grammar/v1/index.html#validation-rules
35+
[wdl-grammar-validation]: https://docs.rs/wdl-grammar/latest/wdl_grammar/v1/index.html#validation-rules

wdl-ast/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
### Changed
1313

14+
* Conform to definition of body as outlined in #12 (#62, contributed by @a-frantz)
1415
* Changes the singular `Group` feature of lint warnings to one or more `Tags` (#37, contributed by @a-frantz)
1516

1617
## 0.1.0 — 12-17-2023

wdl-ast/src/v1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//!
1212
//! The following abstract syntax tree linting rules are supported for WDL 1.x:
1313
//!
14-
//! | Name | Code | Group | Documentation |
14+
//! | Name | Code | Tags | Documentation |
1515
//! |:--------------------------|:-----------|:-------------|:-----------------------------------:|
1616
//! | `matching_parameter_meta` | `v1::W003` | Completeness | [Link](lint::MatchingParameterMeta) |
1717

wdl-ast/src/v1/lint/matching_parameter_meta.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,7 @@ impl<'a> MatchingParameterMeta {
6262
"missing parameter meta within {}: {}",
6363
context, parameter
6464
))
65-
.body(format!(
66-
"Each input parameter within a {} should have an associated `parameter_meta` \
67-
entry with a detailed description of the input.",
68-
context
69-
))
65+
.body(self.body())
7066
.fix(
7167
"Add a key to a `parameter_meta` block matching the parameter's exact name with a \
7268
detailed description of the input.",
@@ -89,13 +85,13 @@ impl<'a> MatchingParameterMeta {
8985
lint::warning::Builder::default()
9086
.code(self.code())
9187
.level(lint::Level::Medium)
92-
.tags(TagSet::new(&[lint::Tag::Completeness]))
88+
.tags(self.tags())
9389
.push_location(location.clone())
9490
.subject(format!(
9591
"extraneous parameter meta within {}: {}",
9692
context, parameter
9793
))
98-
.body("A parameter meta entry with no corresponding input parameter was detected")
94+
.body(self.body())
9995
.fix("Remove the parameter meta entry")
10096
.try_build()
10197
.unwrap()
@@ -112,6 +108,12 @@ impl<'a> Rule<&'a v1::Document> for MatchingParameterMeta {
112108
TagSet::new(&[lint::Tag::Completeness])
113109
}
114110

111+
fn body(&self) -> &'static str {
112+
"Each input parameter within a task or workflow should have an associated `parameter_meta` \
113+
entry with a detailed description of the input. Non-input keys are not permitted within \
114+
the `parameter_meta` block."
115+
}
116+
115117
fn check(&self, tree: &'a v1::Document) -> lint::Result {
116118
let mut warnings = VecDeque::new();
117119

wdl-core/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313

1414
### Changed
1515

16+
* Conform to definition of body as outlined in #12 (#62, contributed by @a-frantz)
1617
* Changes the singular `Group` feature of lint warnings to one or more `Tags` (#37, contributed by @a-frantz)
1718

1819
## 0.1.0 — 12-17-2023

wdl-core/src/concern/lint.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ pub trait Rule<E>: std::fmt::Debug + Sync {
7979
/// Get the lint tags for this lint rule.
8080
fn tags(&self) -> TagSet;
8181

82+
/// Get the body of the lint rule.
83+
fn body(&self) -> &'static str;
84+
8285
/// Checks the tree according to the implemented lint rule.
8386
fn check(&self, tree: E) -> Result;
8487
}

wdl-grammar/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6363

6464
### Changed
6565

66+
* Conform to definition of body as outlined in #12 (#62, contributed by @a-frantz)
6667
* Changes the `preamble_comment` rule so that continuous blocks of comments are reported.
6768
Also permits triple+ pound sign comments outside of the preamble. (#55, contributed by @a-frantz)
6869
* Changes the `snake_case` rule so that lowercase letters can be adjacent to digits without triggering

wdl-grammar/src/v1.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515
//!
1616
//! The following parse tree linting rules are supported for WDL 1.x:
1717
//!
18-
//! | Name | Code | Group | Documentation |
19-
//! |:------------------------|:-----------|:-------------|:---------------------------------:|
20-
//! | `whitespace` | `v1::W001` | Style | [Link](lint::Whitespace) |
21-
//! | `no_curly_commands` | `v1::W002` | Pedantic | [Link](lint::NoCurlyCommands) |
22-
//! | `mixed_indentation` | `v1::W004` | Style | [Link](lint::MixedIndentation) |
23-
//! | `missing_runtime_block` | `v1::W005` | Completeness | [Link](lint::MissingRuntimeBlock) |
24-
//! | `snake_case` | `v1::W006` | Naming | [Link](lint::SnakeCase) |
25-
//! | `newline_eof` | `v1::W007` | Spacing | [Link](lint::NewlineEOF) |
26-
//! | `document_preamble` | `v1::W009` | Spacing | [Link](lint::DocumentPreamble) |
27-
//! | `preamble_comment` | `v1::W010` | Style | [Link](lint::PreambleComment) |
28-
//! | `one_empty_line` | `v1::W011` | Spacing | [Link](lint::OneEmptyLine) |
29-
//! | `double_quotes ` | `v1::W012` | Naming | [Link](lint::DoubleQuotes) |
18+
//! | Name | Code | Tags | Documentation |
19+
//! |:--------------------------|:-----------|:--------------------------|:---------------------------------:|
20+
//! | `whitespace` | `v1::W001` | Spacing, Style | [Link](lint::Whitespace) |
21+
//! | `no_curly_commands` | `v1::W002` | Clarity | [Link](lint::NoCurlyCommands) |
22+
//! | `mixed_indentation` | `v1::W004` | Spacing, Style, Clarity | [Link](lint::MixedIndentation) |
23+
//! | `missing_runtime_block` | `v1::W005` | Completeness, Portability | [Link](lint::MissingRuntimeBlock) |
24+
//! | `snake_case` | `v1::W006` | Naming, Style, Clarity | [Link](lint::SnakeCase) |
25+
//! | `newline_eof` | `v1::W007` | Spacing, Style | [Link](lint::NewlineEOF) |
26+
//! | `document_preamble` | `v1::W009` | Spacing, Style | [Link](lint::DocumentPreamble) |
27+
//! | `preamble_comment` | `v1::W010` | Style | [Link](lint::PreambleComment) |
28+
//! | `one_empty_line` | `v1::W011` | Spacing, Style | [Link](lint::OneEmptyLine) |
29+
//! | `double_quotes` | `v1::W012` | Style, Clarity | [Link](lint::DoubleQuotes) |
3030
3131
use pest::iterators::Pair;
3232
use pest::Parser as _;

wdl-grammar/src/v1/lint/document_preamble.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ impl<'a> DocumentPreamble {
3333
.level(lint::Level::Low)
3434
.tags(self.tags())
3535
.subject("Improperly placed version declaration")
36-
.body(
37-
"The version declaration must be the first line of a WDL document or immediately \
38-
following exactly one blank line and any preamble comments.",
39-
)
36+
.body(self.body())
4037
.push_location(location)
4138
.fix(
4239
"Move the version declaration to the first line of the WDL document or \
@@ -57,7 +54,7 @@ impl<'a> DocumentPreamble {
5754
.level(lint::Level::Low)
5855
.tags(self.tags())
5956
.subject("Leading whitespace detected")
60-
.body("No whitespace is allowed at the beginning of the document")
57+
.body(self.body())
6158
.push_location(location)
6259
.fix("Remove leading whitespace.")
6360
.try_build()
@@ -75,6 +72,14 @@ impl<'a> Rule<&Pair<'a, v1::Rule>> for DocumentPreamble {
7572
TagSet::new(&[Tag::Spacing, Tag::Style])
7673
}
7774

75+
fn body(&self) -> &'static str {
76+
"The document preamble is defined as anything before the version declaration statement and \
77+
the version declaration statement itself. Only comments and whitespace are permitted \
78+
before the version declaration. If there are no comments, the version declaration must be \
79+
the first line of the document. If there are comments, there must be exactly one blank \
80+
line between the last comment and the version declaration."
81+
}
82+
7883
fn check(&self, tree: &Pair<'_, v1::Rule>) -> lint::Result {
7984
let mut warnings = VecDeque::new();
8085

wdl-grammar/src/v1/lint/double_quotes.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl<'a> DoubleQuotes {
3131
.tags(self.tags())
3232
.push_location(location)
3333
.subject("string defined with single quotes")
34-
.body("All strings should be defined using double quotes.")
34+
.body(self.body())
3535
.fix("Change the single quotes to double quotes.")
3636
.try_build()
3737
.unwrap()
@@ -48,6 +48,12 @@ impl<'a> Rule<&'a Pair<'a, v1::Rule>> for DoubleQuotes {
4848
TagSet::new(&[lint::Tag::Clarity, lint::Tag::Style])
4949
}
5050

51+
fn body(&self) -> &'static str {
52+
"All strings should be defined using double quotes. There is no semantic difference \
53+
between single and double quotes in WDL, but double quotes should be used exclusively to \
54+
ensure consistency and avoid any confusion."
55+
}
56+
5157
fn check(&self, tree: &'a Pair<'_, v1::Rule>) -> lint::Result {
5258
let mut warnings = VecDeque::new();
5359

0 commit comments

Comments
 (0)