Danny Mösch
c1ffdfe891
Enable prefer_condition_list rule ( #6163 )
2025-07-12 09:41:00 -04:00
Danny Mösch
6af2aed49d
Ensure that closure_end_indentation doesn't drop comments ( #6158 )
2025-07-09 15:54:59 -04:00
Danny Mösch
599e51a5a2
Format code ( #6151 )
2025-07-02 17:50:53 -04:00
Rodion Ivashkov
097bef27ef
Fix configuration handling in multiline_parameters for stricter validation ( #6148 )
2025-07-02 17:04:45 -04:00
Danny Mösch
546f71bb2d
Add additional newline to first token in file ( #6141 )
...
For all first tokens in a line the newline character causing the new
line is part of the leading trivia. The only exception is the very first
token in a file because at the beginning of a file, there is no previous
line that needs to be broken.
2025-06-27 10:28:24 +02:00
JP Simard
f7f3caa50e
Migrate TrailingWhitespaceRule from SourceKit to SwiftSyntax ( #6117 )
...
## 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
2025-06-24 21:12:32 -04:00
JP Simard
ab7d117030
Migrate FileHeaderRule from SourceKit to SwiftSyntax ( #6112 )
...
## Summary
Convert FileHeaderRule to use SwiftSyntax instead of SourceKit for
improved performance and better handling of file header comments,
shebangs, and doc comments.
## Key Technical Improvements
- **Enhanced shebang support** properly skipping past `#!/usr/bin/env swift` lines
- **Better comment type discrimination** excluding doc comments from header analysis
- **Accurate position calculation** converting between UTF-8 and UTF-16 offsets for regex matching
- **Improved trivia traversal** for comprehensive header comment collection
- **SwiftLint command filtering** to exclude directive comments from header content
## Migration Details
- Replaced `OptInRule` with `@SwiftSyntaxRule(optIn: true)` annotation
- Implemented `ViolationsSyntaxVisitor` pattern for file-level analysis
- Added logic to start header collection after shebang.endPosition if present
- Distinguished between regular comments and doc comments (///, /** */)
- Maintained UTF-16 offset calculations for NSRegularExpression compatibility
- Added `skipDisableCommandTests: true` for SwiftSyntax disable command behavior
- Removed unnecessary SourceKittenFramework import
2025-06-24 09:48:25 -04:00
Kent Kaseda
c22de52b9b
Respect ignore_swiftui_view_bodies option in view builders and preview macros/providers ( #6075 )
...
Co-authored-by: Danny Mösch <danny.moesch@icloud.com >
2025-06-22 01:32:48 +02:00
JP Simard
5a2cf4b1fe
Remove dead code ( #6125 )
...
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
2025-06-21 15:19:37 -04:00
JP Simard
cc03c83eb9
Migrate ClosureEndIndentationRule from SourceKit to SwiftSyntax ( #6109 )
...
* Migrate ClosureEndIndentationRule from SourceKit to SwiftSyntax
- Converted rule to SwiftSyntax
- Implemented recursive anchor detection for method chains
- Fixed indentation calculation for trailing closures
- Fixed correction logic to properly handle existing whitespace
* Revert debug changes to OSSCheck
* Count whitespace for indentation, not first non-whitespace position
* Simplify `hasNewlineInTrivia` calculation
* Update changelog
2025-06-21 11:01:20 -04:00
Matt Pennig
1e25cf6be6
Migrate VerticalWhitespaceRule from SourceKit to SwiftSyntax ( #6103 )
...
* Migrate VerticalWhitespaceRule from SourceKit to SwiftSyntax
* Adds tests for new horizontal whitespace behavior
2025-06-19 17:31:51 -04:00
Danny Mösch
f961ad1728
Prefer string blocks ( #6090 )
2025-06-15 16:00:39 -04:00
Danny Mösch
a3aec89e21
Add test case for trailing comma in multiline arguments ( #6085 )
2025-05-21 07:29:00 -04:00
Kent Kaseda
e1ac6f8607
Remove validates_start_with_lowercase option entirely ( #6077 )
2025-05-15 16:48:00 -04:00
Danny Mösch
47335d7f95
Remove tracking of correction positions ( #5950 )
...
Report number of corrections per file instead.
2025-04-05 06:04:37 -04:00
Danny Mösch
2578cb3862
Use SwiftSyntax version 601.0.0 ( #6003 )
2025-04-03 21:27:57 +02:00
Danny Mösch
b14272d4f2
Rewrite type_contents_order rule with SwiftSyntax ( #6002 )
2025-03-17 20:15:02 +01:00
Martin Redington
5517d233fd
Started to add rationales ( #5681 )
2025-03-06 10:16:30 +00:00
Danny Mösch
ae8aeb3995
Add option to disable redundant_discardable_let in SwiftUI view bodies ( #5929 )
2025-01-03 19:30:35 +01:00
Danny Mösch
ff21ff796c
Specify rule properties in attribute
2024-12-26 20:40:29 +01:00
Dinesh Sharma
8e3b50fa61
Add new category for @IBSegueAction to type_contents_order rule ( #5524 )
...
Co-authored-by: Danny Mösch <danny.moesch@icloud.com >
2024-12-14 18:02:54 -05:00
Jared Grubb
c45427e08b
Handle @unknown default in vertical_whitespace_between_cases rule ( #5843 )
2024-12-01 01:17:08 +00:00
Kim de Vos
2a723d0042
Add new option max_number_of_single_line_parameters to multiline_parameters rule ( #5781 )
...
Co-authored-by: Danny Mösch <danny.moesch@icloud.com >
2024-11-24 14:14:08 +00:00
Danny Mösch
cafed078fa
Silence superfluous_else rule for availability conditions ( #5857 )
2024-11-16 21:54:59 +00:00
Danny Mösch
707a63daf0
Allow closures being directly called to be wrapped into parentheses ( #5856 )
2024-11-16 10:25:50 +00:00
Martin Redington
01f5ecd64a
Replace description.identifier with identifier ( #5837 )
2024-10-26 14:46:03 +01:00
Martin Redington
9e78054781
Preserve trailing comments for opening_brace rule ( #5780 )
2024-09-08 12:31:45 +01:00
Aryaman Sharda
ae3f0c4df9
Add new attribute_name_spacing rule ( #5669 )
...
Co-authored-by: Danny Mösch <danny.moesch@icloud.com >
2024-09-06 08:26:47 -04:00
Leonardo de Sousa Rodrigues
3bb8014782
Add options to opening_brace rule that silence it on multiline statements and types ( #5521 )
...
Co-authored-by: Danny Mösch <danny.moesch@icloud.com >
2024-08-24 05:44:33 -04:00
Danny Mösch
74f4778070
Align left brace of additional trailing closures with right brace of previous trailing closure ( #5761 )
2024-08-19 17:26:48 -04:00
Danny Mösch
d5f7f9c29a
Align left closure brace with associated parent function call ( #5760 )
2024-08-19 20:19:57 +00:00
Danny Mösch
314c91f426
Check all nested if expressions in contrasted_opening_brace rule ( #5759 )
2024-08-19 15:42:10 -04:00
Danny Mösch
248ffafd83
Make contrasted_opening_brace opt-in
2024-08-07 01:02:45 +02:00
Danny Mösch
b67e82a832
Extract new contrasted_opening_brace rule from opening_brace rule ( #5723 )
2024-08-03 18:03:41 +02:00
Danny Mösch
87bc82e7b5
Restrict prefer_key_path to standard functions and function arguments ( #5722 )
...
By default, the rule triggers on and corrects closures used in functions
it "knows". With the option extending the rule, it now also triggers on
closures used in "safe" contexts, where "safe" means that a correction
would not lead to uncompilable code (ideally).
2024-08-03 15:01:40 +00:00
Danny Mösch
88191fe58e
Enable prefer_key_path rule and fix all violations ( #5721 )
2024-08-03 14:21:47 +02:00
UIApplicationMain
5f804d005b
Remove extra case statement in example ( #5717 )
2024-07-31 18:40:21 +02:00
Danny Mösch
e44bf9adb6
Add new brace_on_new_line option to opening_brace rule ( #5708 )
2024-07-30 22:23:01 +02:00
Danny Mösch
39b7c9f134
Move and refactor methods ( #5706 )
2024-07-27 16:24:32 +00:00
Danny Mösch
2cc1acb683
Check at the violation position if a correction can be applied ( #5682 )
2024-07-20 23:22:54 +02:00
Hayashi Tatsuya
cb0f5ab007
Verify and document fixed opening_brace correction ( #5620 )
...
Co-authored-by: Danny Mösch <danny.moesch@icloud.com >
2024-07-20 11:36:24 -04:00
Danny Mösch
9f8a3f5662
Fix some typos ( #5683 )
2024-07-20 11:22:32 -04:00
Danny Mösch
238415b4f7
Place corrections optionally into violations ( #5680 )
...
This avoids maintaining two lists of objects.
2024-07-20 16:24:17 +02:00
Martin Redington
3421f5f46d
Enable multiline_parameters rule, and fix all cases ( #5664 )
2024-07-18 01:48:02 +01:00
Danny Mösch
2442e10f13
Avoid needless indentation in examples ( #5675 )
2024-07-16 13:57:05 -04:00
Danny Mösch
cc4b569c54
Enable unused_parameter rule and fix all violations ( #5673 )
2024-07-14 11:20:50 -04:00
Danny Mösch
e48bdb7adf
Add new unused_parameter rule ( #5668 )
2024-07-14 05:31:29 -04:00
Martin Redington
c6a7dd2ecd
Fix implicit return rewriting ( #5661 )
2024-07-10 13:24:09 +01:00
Martin Redington
ed10aec5f8
Enable implicit_return and fix all violations ( #5658 )
2024-07-10 12:15:19 +01:00
Koichiro Ueki
aa9f474cb9
Add new no_empty_block rule ( #5617 )
2024-06-29 13:13:41 +02:00