-
Notifications
You must be signed in to change notification settings - Fork 8
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
fix: lint tweaks #206
Conversation
There was a problem hiding this 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.
Co-authored-by: Peter Huene <peter@huene.dev>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
let end_offset = if s.ends_with('\n') { | ||
1 | ||
} else if s.ends_with("\r\n") { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this correct now?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this right?
There was a problem hiding this comment.
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 🤷
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:
changes (when appropriate).
CHANGELOG.md
(see"keep a changelog" for more information).