-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
check for unbalanced tick pairs in doc-markdown lint #7357
Conversation
r? @phansch (rust-highfive has picked a reviewer for you, use r? to override) |
0fdcaa8
to
bcf64f1
Compare
Hey, have you decided where you want to span the lint after your changes? I think that that would affect the implementation a bit. The example output would suggest to me that your change points to the first back-tick. Is that correct? I was thinking that the implementation could be simplified by spanning the lint over the complete paragraph instead of a single backtick. The bug ticket is actually more about the fact that the wrong spans have been marked. I believe the issue would also count as fixed when the whole thing would be marked with a message like: the backticks are unbalanced, one might be missing a pair. The implementation might then be pretty straight forward, as you only have to check if text contains backticks. I've done some testing by printing the parsed tokens and these are the results:
Results:
|
Yes, currently I have the span only covering the first backtick. The other issue I was having is that if there are other errors after the unbalanced backtick, the spans on their lints are not correct because
I'm not sure if this is possible to fix. Should I just stop clippy from linting on a paragraph once it discovers unbalanced ticks?
That's a good idea, thanks! |
This is not necessary but would be a very nice feature. It could otherwise happen that a single change like adding one tick produces several other lint messages. I think that having this lint shadow all/most other doc lint's for one pharagraph would be good! :) |
Oops, not so sure what happened there. Sorry about that. Is there a way to remove those extra commits or does it not matter? |
Yes there is, you can try this: #7270 (review). I know that it worked for someone else :). Rebasing can be a bit tricky at times. Let me know if you need some more help 🙃 |
Thank you! That worked. Seems like I just went too far back in the commit history. I think this PR is ready for review now. Thanks for your help! |
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.
The implementation before and after your changes ignores HTML, could you add that as a note to the lint documentation in the Known Problems section.
The rest of the implementation looks good 👍 🙃
562200c
to
54467ca
Compare
Thanks for the review! I've applied your changes. I also had to change some tests to pass CI because there is a 200 line limit on |
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.
Thanks for the review! I've applied your changes. I also had to change some tests to pass CI because there is a 200 line limit on .stderr files. I removed some parts that seemed redundant, but if it's better I can split the tests into two files to keep them all.
It's usually better to add a second test file in such a case, that will also make it easier in the future to expand the tests if needed. For instance, to add lint support in headlines or edge cases.
Thank you for applying the requested changes so quickly. The implementation looks good to me besides the marked places. 👍
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've notices one last false negative by running cargo lintcheck
. The current implementation ignores items inside lists, as those use the Start(Item)
and End(Item)
events. Here is a simple reproduction:
#![deny(clippy::doc_markdown)]
/// - machine: x86_64,
pub fn last_fp() {}
// The x86_64 should trigger the lint validation for identifiers as it not inside backticks
I would approve of this PR once this last FP is fixed and test are added for it. The rest looks wonderful to me 🙃
The tool otherwise noted one correct unbalanced backtick here.
Thank you! While I'm at it, are there any other tags I should include? The full list is fonud here. |
Nevermind, none of the other tags can have backticks in them. I've added support for list items. |
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.
LGTM
cc: @flip1995 could you double check my review?
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.
Just one question
Thanks! @bors r=xFrednet,flip1995 |
📌 Commit 20cb1bc has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
fixes #6753
changelog: check for unbalanced tick pairs in doc-markdown lint