Commit Graph

190 Commits

Author SHA1 Message Date
Danny Mösch 951d03cf00 Silence prefer_self_in_static_references on generics lists in classes and extensions (#6676) 2026-05-28 23:50:38 +02:00
Danny Mösch 792032480e Support SwiftLint on Windows (#6636)
Co-authored-by: Saleem Abdulrasool <compnerd@compnerd.org>
Co-authored-by: Roman Lavrov <roman.lavrov@thebrowser.company>
2026-05-27 22:02:06 +02:00
Danny Mösch 43ce7e2563 Fix explicit_self false positives around string interpolation (#6662)
Co-authored-by: Jeff Mark <jffmrk@users.noreply.github.com>
2026-05-25 04:53:00 -04:00
itsybitsybootsy a6c4fccb3f Surface violations of prefer_self_in_static_references inside extensions (#6639)
Co-authored-by: itsybitsybootsy <lammlu19>
Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-24 12:45:45 -04:00
theamodhshetty ef026db5af Fix prefer_self_in_static_references for shadowed nested types (#6552)
Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
2026-04-19 09:35:59 -04:00
Pavlo Tanaiev 9bc16b539b Fix indentation_width false positives for multi-line conditions (#6505)
Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
2026-04-19 09:08:24 -04:00
theamodhshetty bd662b7009 Catch guard else spacing in statement_position rule (#6543) 2026-04-10 15:51:50 -04:00
Danny Mösch 29a71dd50d Track variables declared in tuples (#6565) 2026-03-27 19:44:12 +01:00
theamodhshetty 15d7a3d9ef Add ignore_attributes option to implicit_optional_initialization (#6513) 2026-02-28 10:52:08 +00:00
Danny Mösch 987f3603ae Use start position of closure to check if rule is disabled (#6458) 2026-01-23 20:52:05 +01:00
Danny Mösch 335edded41 Inline dedicated rule test (#6459) 2026-01-23 14:25:19 -05:00
Danny Mösch 6de2cc9587 Use SwiftSyntax 6.4 pre-release 2026-01-20 (#6447) 2026-01-21 00:00:37 +01:00
tristan-burnside-anz d4585d4814 Exclude bool literals in optional_enum_case_name correction (#6418) 2026-01-08 09:39:47 +00:00
Danny Mösch 44f2ed46a9 Add only_in_closures option to redundant_self to maintain old behavior (#6406) 2026-01-03 07:16:11 -05:00
Danny Mösch 779c5ab94c Keep unwrapped self in extensions for optional types (#6396) 2025-12-27 09:39:39 -05:00
Brett Best fb046797b2 Add handling for access level modifiers on imports (#6377) 2025-12-19 04:10:07 -05:00
Danny Mösch 32c33c2588 Re-enable redundant_self rule (#6368) 2025-12-07 08:11:08 -05:00
Danny Mösch d1cdf8ce20 Extend redundant_self_in_closure to find all redundant selfs (#6346) 2025-12-07 07:49:50 -05:00
Danny Mösch b6c7e045a8 Add new separation option to vertical_whitespace_between_cases (#6334) 2025-11-02 08:53:25 -05:00
Danny Mösch b51759599e Rewrite vertical_whitespace_between_cases rule with SwiftSyntax (#6333) 2025-11-02 01:40:23 -05:00
Danny Mösch ede316d453 Use SwiftSyntax 6.3 pre-release 2025-10-30 (#6330) 2025-11-01 13:34:08 +01:00
Copilot 038135e14d Enable prefer_key_path rule (#6331)
Co-authored-by: SimplyDanny <16365760+SimplyDanny@users.noreply.github.com>
2025-10-31 16:58:41 +00:00
Danny Mösch 7b4335abea Fix correction of sorted_imports rule for leading comments case (#6318) 2025-10-26 08:26:49 +01:00
Nandhini Subramani 6619ca9c10 Add isolation parameter to modifier_order rule (#6316) 2025-10-22 09:40:45 +02:00
Nandhini Subramani 2c2ca671ed Add ignores_literals option to trailing_whitespace rule (#6309) 2025-10-18 04:31:52 -04:00
Tatsuyuki Kobayashi 6dfad2cf1c Fix false positive with #Preview macro in closure_end_indentation (#6306) 2025-10-16 05:28:02 -04:00
Danny Mösch 25ef2ea69b Remove trailing comma (#6297) 2025-10-13 22:56:24 +02:00
Nandhini Subramani a23e4c98bc Exclude integer generic parameters from generic_type_name and handle them in identifier_name (#6289) 2025-10-10 23:07:41 +02:00
Danny Mösch 4065fc8437 Enable upcoming feature MemberImportVisibility (#6286) 2025-10-08 08:12:05 +02:00
Danny Mösch a6247c24e4 Rewrite sorted_imports rule with SwiftSyntax (#6280) 2025-10-05 17:00:27 +02:00
Danny Mösch e9718145cb Rewrite modifier_order rule with SwiftSyntax (#6279) 2025-10-04 16:39:17 +02:00
Danny Mösch 7348cf0f4a Use SwiftSyntax 6.3 pre-release 2025-09-15 (#6206) 2025-09-29 14:59:47 +02:00
Danny Mösch 74e6c3625f Ignore redundant_discardable_let in nested SwiftUI scopes (#6257) 2025-09-25 11:35:28 -04:00
Danny Mösch 4859fa8e82 Ensure that headers matched against always end in a newline (#6234) 2025-09-04 23:09:35 +02:00
Danny Mösch 6946309f9b Consider other expression types before function calls (#6226) 2025-09-03 14:33:10 +02:00
Danny Mösch 57d6752a2a Merge function_name_whitespace and operator_whitespace rules (#6217) 2025-09-03 00:34:22 +02:00
Rodion Ivashkov 91b26549c4 Add function_name_whitespace rule to validate and autocorrect spacing around function names (#6156)
Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
2025-08-30 10:40:44 -04:00
Danny Mösch 77050e8c40 Enable a fully statically linked Linux executable (#6211)
If SwiftLint is built from this state using the Swift SDK, we'll get a
large self-contained Linux executable that runs without loading SourceKit.
It can do that by disabling any rule that requires SourceKit.

With `SWIFTLINT_DISABLE_SOURCEKIT` set on a normally (dynamically linked)
binary, the behavior is the same. That's different from the previously
reported more serious warnings.
2025-08-30 10:02:38 -04:00
Leopold Lemmermann 2677d5ee6e Add new implicit_optional_initialization replacing redundant_optional_initialization (#6165)
The new rule covers both cases, initialization with `= nil` and without, consistently.

Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
2025-08-13 10:08:49 +00:00
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