-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Labels
bugUnexpected and reproducible misbehavior.Unexpected and reproducible misbehavior.
Description
New Issue Checklist
- I've Updated SwiftLint to the latest version.
- I've searched for existing GitHub issues.
Bug Description
When running swiftlint --fix, the trailing_closure rule ignores // swiftlint:disable:this trailing_closure comments and still "corrects" the code. This produces syntactically invalid Swift code that does not compile.
Complete output when running SwiftLint
$ echo 'let dataSource = RxTableViewSectionedReloadDataSource<SectionModel>(
configureCell: { _, tableView, indexPath, item in // swiftlint:disable:this trailing_closure - false positive
return cell
}
)' | swiftlint --fix --use-stdin
let dataSource = RxTableViewSectionedReloadDataSource<SectionModel> { _, tableView, indexPath, item in // swiftlint:disable:this trailing_closure
return cell
}
Before:
let dataSource = RxTableViewSectionedReloadDataSource<SectionModel>(
configureCell: { _, tableView, indexPath, item in // swiftlint:disable:this trailing_closure - false positive
return cell
}
)After:
let dataSource = RxTableViewSectionedReloadDataSource<SectionModel> { _, tableView, indexPath, item in // swiftlint:disable:this trailing_closure
return cell
}
Environment
- SwiftLint version (run
swiftlint versionto be sure): 0.63.1 - Installation method used (Homebrew, CocoaPods, building from source, etc): mise
- Xcode version (run
xcodebuild -versionto be sure): 16.2 - Configuration file:
opt_in_rules:
- trailing_closure
trailing_closure:
severity: errorExpected behavior
The // swiftlint:disable:this trailing_closure comment should prevent autocorrect from modifying this line. The code should remain unchanged.
Actual behavior
The // swiftlint:disable:this trailing_closure comment is ignored during autocorrect
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugUnexpected and reproducible misbehavior.Unexpected and reproducible misbehavior.