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
{{ message }}
Repository navigation
swiftlint --fix ignores disable:this comment for prefer_key_path rule #6466
When running swiftlint --fix, the prefer_key_path rule applies its auto-correction even when the line has an explicit // swiftlint:disable:this prefer_key_path comment. The disable comment should prevent any auto-fix from being applied.
Environment
SwiftLint version: 0.63.2
Installation method: mise
Xcode version: Xcode 26.2 (Build version 17C52)
Swift version: Apple Swift version 6.2.3 (swiftlang-6.2.3.3.21 clang-1700.6.3.2)
macOS version: 26.2
Steps to Reproduce
Create a Swift file with the following content:
importRxSwiftletobservable:Observable<SomeType>=...letresult=observable.map{$0.placeholder} // swiftlint:disable:this prefer_key_path - using a key path here leads to a compilation error
Run swiftlint --fix
Expected Behavior
The line should remain unchanged because the prefer_key_path rule is explicitly disabled for this line via the // swiftlint:disable:this prefer_key_path comment.
The code should stay as:
.map{$0.placeholder} // swiftlint:disable:this prefer_key_path - using a key path here leads to a compilation error
Actual Behavior
SwiftLint applies the auto-fix despite the disable comment, changing the code to:
.map(\.placeholder) // swiftlint:disable:this prefer_key_path - using a key path here leads to a compilation error
This leaves behind a now-nonsensical disable comment on code that already uses the key path syntax.
Activity