Skip to content

Commit b690c0c

Browse files
committed
Migrate VerticalWhitespaceOpeningBracesRule to SwiftSyntax
## Summary Convert VerticalWhitespaceOpeningBracesRule to use SwiftSyntax instead of SourceKit for improved performance and better detection of empty lines after opening braces. ## Key Technical Improvements - **Enhanced trivia analysis** for accurate empty line detection after opening braces - **Proper handling of closure "in" keywords** with context-aware detection - **Improved correction logic** handling all newline types (LF, CR, CRLF) consistently - **SwiftSyntax visitor pattern** replacing regex-based detection for better accuracy - **Comprehensive token analysis** supporting all opening brace types (`{`, `[`, `(`) - **Accurate position tracking** for violation start and end positions ## Migration Details - Replaced `CorrectableRule, OptInRule` with `@SwiftSyntaxRule(correctable: true, optIn: true)` - Implemented `ViolationsSyntaxVisitor` for detecting violations in token trailing trivia - Implemented `ViolationsSyntaxRewriter` for correcting violations across different syntax contexts - Added proper handling of closures, code blocks, arrays, and tuples - Maintained exact position reporting for violation locations - Preserved all existing test cases and rule behavior
1 parent 81474e3 commit b690c0c

File tree

2 files changed

+329
-42
lines changed

2 files changed

+329
-42
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
* Migrate `vertical_whitespace` rule from SourceKit to SwiftSyntax for improved performance.
3030
[Matt Pennig](https://github.com/pennig)
3131

32+
* Migrate `vertical_whitespace_opening_braces` rule from SourceKit to SwiftSyntax for improved
33+
performance and fewer false positives.
34+
[JP Simard](https://github.com/jpsim)
35+
3236
### Bug Fixes
3337

3438
* Improved error reporting when SwiftLint exits, because of an invalid configuration file

0 commit comments

Comments
 (0)