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

fix: lint tweaks #206

Merged
merged 14 commits into from
Oct 4, 2024
Merged

fix: lint tweaks #206

merged 14 commits into from
Oct 4, 2024

Conversation

a-frantz
Copy link
Member

@a-frantz a-frantz commented Oct 1, 2024

Describe the problem or feature in addition to a link to the issues.

Lots of relatively minor tweaks, mostly to how whitespace is reported in lints.

Before submitting this PR, please make sure:

  • You have added a few sentences describing the PR here.
  • You have added yourself or the appropriate individual as the assignee.
  • You have added at least one relevant code reviewer to the PR.
  • Your code builds clean without any errors or warnings.
  • You have added tests (when appropriate).
  • You have updated the README or other documentation to account for these
    changes (when appropriate).
  • You have added an entry to the relevant CHANGELOG.md (see
    "keep a changelog" for more information).
  • Your commit messages follow the conventional commit style.

@a-frantz a-frantz requested a review from peterhuene October 1, 2024 19:39
@a-frantz a-frantz self-assigned this Oct 1, 2024
@a-frantz a-frantz marked this pull request as ready for review October 1, 2024 20:22
@a-frantz
Copy link
Member Author

a-frantz commented Oct 1, 2024

closes #198
closes #203

Copy link
Collaborator

@peterhuene peterhuene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look great. Just some minor feedback.

wdl-lint/src/rules/blank_lines_between_elements.rs Outdated Show resolved Hide resolved
wdl-lint/src/rules/blank_lines_between_elements.rs Outdated Show resolved Hide resolved
wdl-lint/src/rules/preamble_formatting.rs Outdated Show resolved Hide resolved
@a-frantz a-frantz requested a review from peterhuene October 3, 2024 16:41
Copy link
Collaborator

@peterhuene peterhuene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@a-frantz a-frantz merged commit 341a348 into main Oct 4, 2024
8 checks passed
@a-frantz a-frantz deleted the fix/lint-tweaks branch October 4, 2024 13:54
wdl-lint/src/rules/missing_requirements.rs Show resolved Hide resolved
Comment on lines +260 to +262
let end_offset = if s.ends_with('\n') {
1
} else if s.ends_with("\r\n") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to be handling windows line endings at this level or should it be something at a higher-level that is shared across lints?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that as part of the format PR @claymcleod is introducing some config for this that could hopefully be reused in wdl-lint. So yes, we do want to handle this at a higher level, but that will require some thought as to architecture.

.with_rule(ID)
.with_highlight(span)
}

/// Creates a diagnostic for a comment inside the version statement.
fn comment_inside_version(span: Span) -> Diagnostic {
Diagnostic::error("unexpected comment inside the version statement")
Diagnostic::note("unexpected comment inside the version statement")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can stay an error. I think that's a reasonable position to take

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that jives with the definitions we now have here

The comment doesn't interrupt parsing/validation/meaning/etc, so error would be wrong. I suppose warning could fit as it's potentially confusing? But IMO it really just boils down to style (i.e. a note), although a particularly egregious example of bad style.

note[CommentWhitespace]: comment delimiter should be followed by a single space
┌─ tests/lints/missing-comment-space/source.wdl:1:1
1 │ ##This preamble comment is missing a space.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an expected removal?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, click expand down and you'll see:

note[PreambleFormatting]: preamble comments must start with `##` and have at least one space between the `##` and the comment text
  ┌─ tests/lints/missing-comment-space/source.wdl:1:1
  │
1 │ ##This preamble comment is missing a space.
  │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

note[CommentWhitespace]: comment has too much indentation
┌─ tests/lints/preamble-comment-after-version/source.wdl:2:8
2 │ ## Bad leading whitespace!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Expand 'up' to see:

note[PreambleFormatting]: unnecessary whitespace in document preamble
  ┌─ tests/lints/preamble-comment-after-version/source.wdl:2:1
  │
2 │        ## Bad leading whitespace!
  │ ^^^^^^^

note[VersionFormatting]: expected exactly one blank line after the version statement
┌─ tests/lints/one-line-after-version/source.wdl:5:12
5 │ version 1.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe? I changed the code so that VersionFormatting won't emit anything if it's the last thing (aside from whitespace) in the document. That case is a clear error (which is already being handled), and the lints emitted at the same time seem inconsequential to me 🤷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lint diagnostic tweaks needed reported whitespace spans look off
3 participants