mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
Ignore array types if their associated Index is accessed (#3970)
This commit is contained in:
+4
-1
@@ -21,7 +21,10 @@
|
||||
|
||||
#### Bug Fixes
|
||||
|
||||
* None.
|
||||
* Ignore array types in `syntactic_sugar` rule if their associated `Index` is
|
||||
accessed.
|
||||
[SimplyDanny](https://github.com/SimplyDanny)
|
||||
[#3502](https://github.com/realm/SwiftLint/issues/3502)
|
||||
|
||||
## 0.47.1: Smarter Appliance
|
||||
|
||||
|
||||
@@ -177,7 +177,7 @@ private final class SyntacticSugarRuleVisitor: SyntaxVisitor {
|
||||
// Skip checks for 'self' or \T Dictionary<Key, Value>.self
|
||||
if let parent = node.parent?.as(MemberAccessExprSyntax.self),
|
||||
let lastToken = Array(parent.tokens).last?.tokenKind,
|
||||
lastToken == .selfKeyword || lastToken == .identifier("Type") || lastToken == .identifier("none") {
|
||||
[.selfKeyword, .identifier("Type"), .identifier("none"), .identifier("Index")].contains(lastToken) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@ internal enum SyntacticSugarRuleExamples {
|
||||
Example("let x: Foo.Optional<String>"),
|
||||
|
||||
Example("let x = case Optional<Any>.none = obj"),
|
||||
Example("let a = Swift.Optional<String?>.none")
|
||||
Example("let a = Swift.Optional<String?>.none"),
|
||||
Example("func f() -> [Array<Int>.Index] { [Array<Int>.Index]() }", excludeFromDocumentation: true)
|
||||
]
|
||||
|
||||
static let triggering = [
|
||||
|
||||
Reference in New Issue
Block a user