You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Prevent vale style review from removing code blocks (#701)
* Prevent vale style review from removing code blocks
The LLM was making overly aggressive suggestions that removed entire
code blocks from documentation. This adds multiple safeguards:
- Add getLinesInCodeBlocks() to detect lines inside fenced code blocks
- Skip any suggestion targeting lines inside code blocks
- Reject suggestions where suggested text is <70% of original length
- Strengthen LLM prompt with explicit "NEVER MODIFY CODE" instructions
- Extract validation helpers to reduce cognitive complexity
Fixes the issue where PR #700 removed 173 lines of code examples.
Co-Authored-By: Claude Opus 4.5 <[email protected]>
* Fix inconsistent length validation and prompt contradiction in vale-style-review
- Make isDestructiveChange use trimmed lengths to match wouldRemoveContent
- Update prompt to reflect actual validation logic (allows 30% shorter text)
This fixes false positives where whitespace-only changes were incorrectly rejected,
and aligns the LLM prompt with the actual 70% length threshold in the code.
* Fix nested code block detection in getLinesInCodeBlocks
The function now tracks the opening backtick count and only closes a code block when encountering a line with at least as many backticks. This prevents nested code blocks (e.g., 4+ backticks wrapping 3-backtick blocks) from being incorrectly detected.
* Fix CommonMark code fence parsing bugs in vale-style-review
- Enforce 3-space indentation limit for code fences per CommonMark spec
- Validate closing fences only accept whitespace after backticks
- Prevent misidentification of indented backticks as fence markers
- Ensure non-whitespace content after backticks keeps fence open
* Fix lint errors in vale-style-review.ts
- Extract magic numbers to constants (MAX_FENCE_INDENT, TAB_STOP_WIDTH)
- Reduce cognitive complexity in getLinesInCodeBlocks by extracting helper functions
- Fix line formatting in isDestructiveChange
Co-Authored-By: Claude Opus 4.5 <[email protected]>
* Fix: Support tilde-fenced code blocks in vale-style-review
The getLinesInCodeBlocks function now detects both backtick ( and ~~~
- Enhanced isValidClosingFence to match opening fence character
- Updated getLinesInCodeBlocks to track fence type
---------
Co-authored-by: Rachel Lee Nabors <[email protected]>
Co-authored-by: Claude Opus 4.5 <[email protected]>
Co-authored-by: Cursor Agent <[email protected]>
0 commit comments