Skip to content

Fix Vale false positives on context lines in PR diffs#181

Merged
theletterf merged 2 commits into
mainfrom
update-vale-sticky-comment
Jun 2, 2026
Merged

Fix Vale false positives on context lines in PR diffs#181
theletterf merged 2 commits into
mainfrom
update-vale-sticky-comment

Conversation

@theletterf
Copy link
Copy Markdown
Member

Summary

  • Vale was flagging lines that were not modified in a PR — only present as context within a diff hunk.
  • The line-range filter extracted hunk headers (@@ -x,y +a,b @@) and treated the entire hunk span as "modified." Any Vale issue on a context line within the hunk was wrongly reported.
  • Confirmed in elastic/docs-content#6796 (15 MappedPages false positives) and elastic/docs-content#6664 (MenuArrowsBold on an unmodified line).

Example: a file with mapped_pages: at line 3. A description: field is added at line 2, producing a hunk @@ -1,4 +1,5 @@ (range 1–6). The old filter saw line 3 as in-range; the new one does not.

Changes

  • vale/lint/action.yml — replace hunk-header extraction with a full patch walk that records only + (added) lines, one entry per line.
  • vale/lint/vale_reporter.py — change the range check from start <= line_num <= end to start <= line_num < end (exclusive upper bound) so a count=1 entry for line N matches exactly N.

Test plan

  • All existing unit tests pass (pytest vale/lint/test_vale_reporter.py — 17 passed)
  • Re-run Vale on elastic/docs-content#6796 after merge and confirm MappedPages warnings are gone
  • Re-run Vale on elastic/docs-content#6664 after merge and confirm MenuArrowsBold warning is gone

🤖 Generated with Claude Code

theletterf and others added 2 commits May 28, 2026 13:40
Keep the Vale PR comment stable by updating it in place and skipping no-op updates when the rendered report is unchanged.

Co-authored-by: OpenAI GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
The line-range filter was extracting hunk headers (@@ -x,y +a,b @@) and
treating the entire hunk span as "modified." Context lines within a hunk
(e.g. mapped_pages at line 3 when only a description was added at line 2)
were wrongly flagged.

Fix: walk the full patch per-file and record only actual '+' lines, one
entry per added line. Change the Python filter to exclusive upper bound
(start <= line < end) so a count=1 entry for line N matches exactly N.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@theletterf theletterf requested a review from a team as a code owner June 2, 2026 14:20
@theletterf theletterf requested a review from Mpdreamz June 2, 2026 14:20
@theletterf theletterf self-assigned this Jun 2, 2026
@theletterf theletterf added the enhancement New feature or request label Jun 2, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

Elastic Docs Style Checker (Vale)

Summary: 21 warnings, 19 suggestions found

⚠️ Warnings (21): Fix when the suggestion improves clarity or correctness.
File Line Rule Message
vale/test-fixtures/sample-violations.md 2 Elastic.MappedPages mapped_pages should only be added or updated in rare scenarios. Talk with your local technical writer before pushing changes to this key.
vale/test-fixtures/sample-violations.md 6 Elastic.Articles Use 'an FAQ' instead of 'a FAQ'. The article depends on pronunciation, not spelling.
vale/test-fixtures/sample-violations.md 6 Elastic.Articles Use 'an HTML' instead of 'a HTML'. The article depends on pronunciation, not spelling.
vale/test-fixtures/sample-violations.md 6 Elastic.Articles Use 'an SQL' instead of 'a SQL'. The article depends on pronunciation, not spelling.
vale/test-fixtures/sample-violations.md 6 Elastic.Articles Use 'an HTML' instead of 'a HTML'. The article depends on pronunciation, not spelling.
vale/test-fixtures/sample-violations.md 7 Elastic.BritishSpellings Use American English spelling 'optimize' instead of British English 'optimise'.
vale/test-fixtures/sample-violations.md 7 Elastic.BritishSpellings Use American English spelling 'customize' instead of British English 'customise'.
vale/test-fixtures/sample-violations.md 7 Elastic.BritishSpellings Use American English spelling 'behavior' instead of British English 'behaviour'.
vale/test-fixtures/sample-violations.md 11 Elastic.DontUse Don't use 'just'.
vale/test-fixtures/sample-violations.md 11 Elastic.DontUse Don't use 'please'.
vale/test-fixtures/sample-violations.md 11 Elastic.DontUse Don't use 'aka'.
vale/test-fixtures/sample-violations.md 20 Elastic.Articles Use 'an FAQ' instead of 'a FAQ'. The article depends on pronunciation, not spelling.
vale/test-fixtures/sample-violations.md 20 Elastic.Articles Use 'an HTML' instead of 'a HTML'. The article depends on pronunciation, not spelling.
vale/test-fixtures/sample-violations.md 20 Elastic.Articles Use 'an SQL' instead of 'a SQL'. The article depends on pronunciation, not spelling.
vale/test-fixtures/sample-violations.md 24 Elastic.BritishSpellings Use American English spelling 'optimize' instead of British English 'optimise'.
vale/test-fixtures/sample-violations.md 24 Elastic.BritishSpellings Use American English spelling 'customize' instead of British English 'customise'.
vale/test-fixtures/sample-violations.md 24 Elastic.BritishSpellings Use American English spelling 'behavior' instead of British English 'behaviour'.
vale/test-fixtures/sample-violations.md 40 Elastic.DontUse Don't use 'just'.
vale/test-fixtures/sample-violations.md 40 Elastic.DontUse Don't use 'please'.
vale/test-fixtures/sample-violations.md 40 Elastic.DontUse Don't use 'aka'.
vale/test-fixtures/sample-violations.md 48 Elastic.Articles Use 'an HTML' instead of 'a HTML'. The article depends on pronunciation, not spelling.
💡 Suggestions (19): Optional style improvements. Apply when helpful.
File Line Rule Message
vale/test-fixtures/sample-violations.md 8 Elastic.WordChoice Consider using 'efficiently' instead of 'Simply', unless the term is in the UI.
vale/test-fixtures/sample-violations.md 8 Elastic.WordChoice Consider using 'allowlist' instead of 'whitelist', unless the term is in the UI.
vale/test-fixtures/sample-violations.md 8 Elastic.WordChoice Consider using 'blocklist' instead of 'blacklist', unless the term is in the UI.
vale/test-fixtures/sample-violations.md 9 Elastic.OxfordComma Use the Oxford comma in 'reading, writing and executing.'.
vale/test-fixtures/sample-violations.md 10 Elastic.Wordiness Consider using 'to' instead of 'In order to'.
vale/test-fixtures/sample-violations.md 10 Elastic.Wordiness Consider using 'because' instead of 'due to the fact that'.
vale/test-fixtures/sample-violations.md 10 Elastic.Wordiness Consider using 'many' instead of 'a large number of'.
vale/test-fixtures/sample-violations.md 12 Elastic.Exclamation Use exclamation points sparingly. Consider removing the exclamation point.
vale/test-fixtures/sample-violations.md 12 Elastic.Exclamation Use exclamation points sparingly. Consider removing the exclamation point.
vale/test-fixtures/sample-violations.md 28 Elastic.WordChoice Consider using 'efficiently' instead of 'Simply', unless the term is in the UI.
vale/test-fixtures/sample-violations.md 28 Elastic.WordChoice Consider using 'allowlist' instead of 'whitelist', unless the term is in the UI.
vale/test-fixtures/sample-violations.md 28 Elastic.WordChoice Consider using 'blocklist' instead of 'blacklist', unless the term is in the UI.
vale/test-fixtures/sample-violations.md 28 Elastic.WordChoice Consider using 'efficient' instead of 'easy', unless the term is in the UI.
vale/test-fixtures/sample-violations.md 32 Elastic.OxfordComma Use the Oxford comma in 'reading, writing and executing.'.
vale/test-fixtures/sample-violations.md 36 Elastic.Wordiness Consider using 'to' instead of 'In order to'.
vale/test-fixtures/sample-violations.md 36 Elastic.Wordiness Consider using 'because' instead of 'due to the fact that'.
vale/test-fixtures/sample-violations.md 36 Elastic.Wordiness Consider using 'many' instead of 'a large number of'.
vale/test-fixtures/sample-violations.md 44 Elastic.Exclamation Use exclamation points sparingly. Consider removing the exclamation point.
vale/test-fixtures/sample-violations.md 44 Elastic.Exclamation Use exclamation points sparingly. Consider removing the exclamation point.

The Vale linter checks documentation changes against the Elastic Docs style guide. To use Vale locally or report issues, refer to Elastic style guide for Vale.

@theletterf theletterf merged commit 601a036 into main Jun 2, 2026
12 of 13 checks passed
@theletterf theletterf deleted the update-vale-sticky-comment branch June 2, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants