feat(#748): add test-with-comment lint - #1255
Open
VasilevNStas wants to merge 2 commits into
Open
Conversation
Contributor
Author
|
@volodya-lombrozo @yegor256 please review this pull request |
Member
|
@VasilevNStas comments are disabled in XMIR now, except the top-level single comment |
Contributor
Author
|
@yegor256 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix #748
What
A new
tests/test-with-commentlint that warns when a test object has acomment before it. A comment that duplicates the test name adds nothing —
the name should be self-explanatory.
How it works
The lint looks at top-level test objects (
/object/o[eo:test-name(@name)],i.e.
+/-prefixed names). The parser puts the comment that precedes atop-level object into
/object/comments/comment. If a test object has anysuch comment, a
warningis reported.Note: this only applies to top-level tests. A comment placed inside an
object right before a nested
+>test is already a parse error("comment is allowed only on top of the file, before metas"), so there is
no nested case to handle.
Why not the earlier attempt (PR #752)
The earlier PR #752 looked for
meta[@key='comment'], but comments are notstored as metas in XMIR — they live in
/object/comments/comment. Thisimplementation uses the correct location.
Tests
catches-test-with-comment— a comment before a top-level test is flaggedallows-test-without-comment— no comment is cleanBoth
mvn test(592 tests) andmvn clean install -Pqulicepass.