## Summary
Convert TrailingWhitespaceRule to use SwiftSyntax instead of SourceKit
for improved performance and better handling of trailing whitespace
detection, especially within block comments.
## Key Technical Improvements
- **Enhanced block comment detection** distinguishing between lines fully
covered by block comments vs lines containing block comments with code
- **Accurate whitespace detection** using CharacterSet.whitespaces for
all Unicode whitespace characters, not just space and tab
- **Improved comment handling** with proper detection of line-ending
comments and multi-line block comment structures
- **Better correction mechanism** using ViolationCorrection ranges
instead of manual string reconstruction
- **Line-based analysis** maintaining efficiency while providing precise
violation positions
## Migration Details
- Replaced `CorrectableRule` with `@SwiftSyntaxRule(correctable: true)`
- Implemented `ViolationsSyntaxVisitor` pattern for line-based validation
- Added `collectLinesFullyCoveredByBlockComments` to properly handle
test framework comment wrapping scenarios
- Distinguished between three comment scenarios: lines fully within block
comments, full-line comments, and lines ending with comments
- Maintained all configuration options (ignores_empty_lines, ignores_comments)
- Preserved exact violation position reporting with UTF-8 offset calculations
In particular lots of stuff that used to be needed with SourceKit that
we no longer need to keep around.
Identified using Periphery: https://github.com/peripheryapp/periphery
Convert LineLengthRule to use SwiftSyntax instead of SourceKit for
improved performance and better detection accuracy.
The SwiftSyntax implementation:
- Uses ViolationsSyntaxVisitor pattern with line-based validation
- Pre-computes ignored lines using helper visitors for efficiency
- Implements pure SwiftSyntax comment detection without SourceKit
- Correctly handles function declarations, multiline strings
- Maintains all configuration options including URL stripping
- Preserves exact line position reporting for violations
## Summary
Convert AccessibilityTraitForButtonRule to use SwiftSyntax instead of
SourceKit for improved performance and better accessibility trait
detection in SwiftUI modifier chains.
## Key Technical Improvements
- **Bidirectional modifier chain analysis** for comprehensive
accessibility trait detection
- **Better context awareness** through SwiftSyntax tree traversal
- **Accurate container exemption logic** for Button/Link components
- **Enhanced gesture detection** supporting `.onTapGesture` and
`.gesture` modifiers
- **Improved performance** with SwiftSyntax visitor pattern over
SourceKit AST parsing
## Migration Details
- Replaced `ASTRule` with `@SwiftSyntaxRule(optIn: true)` annotation
- Implemented `ViolationsSyntaxVisitor` pattern for systematic tree
traversal
- Added bidirectional accessibility trait detection that checks both
before and after tap gestures
- Enhanced exemption logic for inherently accessible containers
(Button, NavigationLink)
- Maintained full compatibility with existing rule behavior and test
cases
Main goal is to bring implementations, rules and examples closer together.
Another advantage is that the rule's layouts are in line with other
`@SwiftSyntaxRule`s.
After the refactoring, violation messages can be
better adapted to the object causing the issue. Violation positions
should be harmonized and more cases for protocols, subscripts and
deinitializers can be added.
Convert FileLengthRule to use SwiftSyntax instead of SourceKit for
improved performance and fewer false positives.
The SwiftSyntax implementation:
- Uses ViolationsSyntaxVisitor pattern with token traversal
- Correctly handles multiline tokens by counting all spanned lines
- Properly excludes comment-only and whitespace-only lines
- Accurately attributes trivia to correct line positions
- Extracts common line range logic to reduce code duplication
Tasks we perform with Sourcery are rather simple and can be replaced
with a basic collection of files and the generation of lists in the
new `swiftlint-dev` command. This spares contributors from installing
either Sourcery or Bazel.