fix: ignore commented inline-test markers#1432
Closed
statxc wants to merge 1 commit into
Closed
Conversation
Contributor
Author
|
@anderdc I hope you are doing well. |
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.
Summary
close #1431
Fix
has_inline_tests()so Rust/Zig/D inline-test detection no longer treats markers inside comments or string literals as real tests.The existing regex remains as a fast prefilter, but matches are now verified against tree-sitter AST nodes:
attribute_item/inner_attribute_itemTestDeclunittest_declarationThis preserves the current file-level inline-test demotion behavior while avoiding false positives from docs, examples, comments, and raw strings.
Problem
has_inline_tests()regex-scanned raw source text. A production Rust file containing#[test]only inside a block comment or raw multiline string was classified as an inline-test file.That caused
calculate_token_score_from_file_changes()to demote the whole file toScoringCategory.TESTand applyTEST_FILE_CONTRIBUTION_WEIGHT = 0.05.Validation
uv run pytest -q tests/validator/test_inline_test_detection.pyuv run pytest -q tests/validator/test_token_scoring_integration.py tests/validator/test_inline_test_detection.pyuv run pytest tests/ -vuv run pre-commit run --all-files --show-diff-on-failureSKIP=pytest uv run pre-commit run --all-files --hook-stage pre-pushResult: full test suite passed, 914 tests.