Skip to content

feat(#748): add test-with-comment lint - #1255

Open
VasilevNStas wants to merge 2 commits into
objectionary:masterfrom
VasilevNStas:fix/issue-748-test-comment
Open

feat(#748): add test-with-comment lint#1255
VasilevNStas wants to merge 2 commits into
objectionary:masterfrom
VasilevNStas:fix/issue-748-test-comment

Conversation

@VasilevNStas

Copy link
Copy Markdown
Contributor

fix #748

What

A new tests/test-with-comment lint that warns when a test object has a
comment 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 a
top-level object into /object/comments/comment. If a test object has any
such comment, a warning is 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 not
stored as metas in XMIR — they live in /object/comments/comment. This
implementation uses the correct location.

Tests

  • catches-test-with-comment — a comment before a top-level test is flagged
  • allows-test-without-comment — no comment is clean

Both mvn test (592 tests) and mvn clean install -Pqulice pass.

@VasilevNStas

Copy link
Copy Markdown
Contributor Author

@volodya-lombrozo @yegor256 please review this pull request

@yegor256

Copy link
Copy Markdown
Member

@VasilevNStas comments are disabled in XMIR now, except the top-level single comment

@VasilevNStas

VasilevNStas commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

@yegor256
Thanks — that is exactly the case this lint targets. Since nested comments are rejected by the parser, the only place a comment can appear is the top-level comment block (/object/comments/comment), right before the single top-level object. The lint flags precisely that: when the top-level object is a test (eo:test-name, i.e. +/- prefixed) and a top-level comment exists, it reports a warning. So it is aligned with the current XMIR behavior, not relying on any nested-comment support.

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.

comments in test code duplicate test names

2 participants