Deprecate `unused_capture_list` rule in favor of the Swift compiler warning (#4656)

This commit is contained in:
Benedek Kozma 2022-12-22 16:33:44 +01:00 committed by GitHub
parent 1a39194f65
commit d76daf5f62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 3 deletions

View File

@ -2,7 +2,10 @@
#### Breaking
* None.
* Deprecate the `unused_capture_list` rule in favor of the Swift compiler
warning. At the same time, make it an opt-in rule.
[Cyberbeni](https://github.com/Cyberbeni)
[#4656](https://github.com/realm/SwiftLint/issues/4656)
#### Experimental

View File

@ -1,6 +1,18 @@
import SwiftSyntax
struct UnusedCaptureListRule: SwiftSyntaxRule, ConfigurationProviderRule {
private let warnDeprecatedOnceImpl: Void = {
queuedPrintError("""
The `\(UnusedCaptureListRule.description.identifier)` rule is now deprecated and will be completely \
removed in a future release due to an equivalent warning issued by the Swift compiler.
"""
)
}()
private func warnDeprecatedOnce() {
_ = warnDeprecatedOnceImpl
}
struct UnusedCaptureListRule: SwiftSyntaxRule, ConfigurationProviderRule, OptInRule {
var configuration = SeverityConfiguration(.warning)
init() {}
@ -121,7 +133,8 @@ struct UnusedCaptureListRule: SwiftSyntaxRule, ConfigurationProviderRule {
)
func makeVisitor(file: SwiftLintFile) -> ViolationsSyntaxVisitor {
Visitor(viewMode: .sourceAccurate)
warnDeprecatedOnce()
return Visitor(viewMode: .sourceAccurate)
}
}