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

revise: relax CommentWhitespace lint #314

Merged
merged 3 commits into from
Jan 24, 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
4 changes: 2 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ Rule specific checks:
(`wdl-ast/src/validation.rs`) and `LintVisitor`
(`wdl-lint/src/visitor.rs`) visitors. These are required to ensure the new
visitor callback will execute.
- [ ] You have run `wdl-gauntlet --refresh` to ensure that there are no
- [ ] You have run `gauntlet --refresh` to ensure that there are no
unintended changes to the baseline configuration file (`Gauntlet.toml`).
- [ ] You have run `wdl-gauntlet --refresh --arena` to ensure that all of the
- [ ] You have run `gauntlet --refresh --arena` to ensure that all of the
rules added/removed are now reflected in the baseline configuration file
(`Arena.toml`).

Expand Down
10 changes: 7 additions & 3 deletions wdl-lint/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Changed

* Relaxed `CommentWhitespace` rule so that it doesn't fire when a comment has extra spaces before it ([#314](https://github.com/stjude-rust-labs/wdl/pull/314)).

## 0.9.0 - 01-17-2025

## Added
### Added

* Improved `ShellCheck` rule fix messages and implemented the `fix` module ([#284](https://github.com/stjude-rust-labs/wdl/pull/284))
* Added a `ShellCheck` rule ([#264](https://github.com/stjude-rust-labs/wdl/pull/264)).
* Added a `RedundantInputAssignment` rule ([#244](https://github.com/stjude-rust-labs/wdl/pull/244)).

## Changed
### Changed

* Upgraded some `note` diagnostics to `warning` in `ContainerValue` rule ([#244](https://github.com/stjude-rust-labs/wdl/pull/244)).

## Fixed
### Fixed

* Shortened many reported spans and ensured all lint diagnostics use a `fix` message ([#260](https://github.com/stjude-rust-labs/wdl/pull/260)).
* `BlankLinesBetweenElements` logic was tweaked to prevent firing a redundant message with `VersionFormatting` rule ([#260](https://github.com/stjude-rust-labs/wdl/pull/260)).
Expand Down
10 changes: 3 additions & 7 deletions wdl-lint/src/rules/comment_whitespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ fn inline_preceding_whitespace(span: Span) -> Diagnostic {
/// Creates a diagnostic when the comment token is not followed by a single
/// space.
fn following_whitespace(span: Span) -> Diagnostic {
Diagnostic::note("comment delimiter should be followed by a single space")
Diagnostic::note("comment delimiter should be followed by at least one space")
.with_rule(ID)
.with_highlight(span)
.with_fix("add a single space after the comment delimiter")
.with_fix("add at least one space after the comment delimiter")
}

/// Creates a diagnostic when non-inline comment has insufficient indentation.
Expand Down Expand Up @@ -206,18 +206,14 @@ impl Visitor for CommentWhitespaceRule {
comment_chars.next();
}

let preamble = n_delimiter == 2;

if let Some('@') = comment_chars.peek() {
n_delimiter += 1;
comment_chars.next();
}

let n_whitespace = comment_chars.by_ref().take_while(|c| *c == ' ').count();

if comment_chars.skip(n_whitespace).count() > 0
&& ((n_whitespace != 1 && !preamble) || (preamble && n_whitespace == 0))
{
if comment_chars.skip(n_whitespace).count() > 0 && n_whitespace == 0 {
state.exceptable_add(
following_whitespace(Span::new(comment.span().start(), n_delimiter)),
SyntaxElement::from(comment.syntax().clone()),
Expand Down
4 changes: 2 additions & 2 deletions wdl-lint/tests/lints/comment-whitespace/source.errors
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
note[CommentWhitespace]: comment delimiter should be followed by a single space
note[CommentWhitespace]: comment delimiter should be followed by at least one space
┌─ tests/lints/comment-whitespace/source.wdl:5:1
5 │ #a bad comment
│ ^
= fix: add a single space after the comment delimiter
= fix: add at least one space after the comment delimiter

note[CommentWhitespace]: comment has too much indentation
┌─ tests/lints/comment-whitespace/source.wdl:6:5
Expand Down
Loading