mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
Change zip.allSatisfy to map ==
This commit is contained in:
+4
-1
@@ -10,7 +10,10 @@
|
||||
|
||||
#### Enhancements
|
||||
|
||||
* None.
|
||||
* Speed up Identical Operands rule by using syntaxmap instead of
|
||||
regular expressions.
|
||||
[PaulTaykalo](https://github.com/PaulTaykalo)
|
||||
[#2918](https://github.com/realm/SwiftLint/issues/2918)
|
||||
|
||||
#### Bug Fixes
|
||||
|
||||
|
||||
@@ -9671,6 +9671,10 @@ expect("foo") == "foo"
|
||||
↓$0 == $0
|
||||
```
|
||||
|
||||
```swift
|
||||
↓a?.b == a?.b
|
||||
```
|
||||
|
||||
```swift
|
||||
↓1 != 1
|
||||
```
|
||||
@@ -9691,6 +9695,10 @@ expect("foo") == "foo"
|
||||
↓$0 != $0
|
||||
```
|
||||
|
||||
```swift
|
||||
↓a?.b != a?.b
|
||||
```
|
||||
|
||||
```swift
|
||||
↓1 === 1
|
||||
```
|
||||
@@ -9711,6 +9719,10 @@ expect("foo") == "foo"
|
||||
↓$0 === $0
|
||||
```
|
||||
|
||||
```swift
|
||||
↓a?.b === a?.b
|
||||
```
|
||||
|
||||
```swift
|
||||
↓1 !== 1
|
||||
```
|
||||
@@ -9731,6 +9743,10 @@ expect("foo") == "foo"
|
||||
↓$0 !== $0
|
||||
```
|
||||
|
||||
```swift
|
||||
↓a?.b !== a?.b
|
||||
```
|
||||
|
||||
```swift
|
||||
↓1 > 1
|
||||
```
|
||||
@@ -9751,6 +9767,10 @@ expect("foo") == "foo"
|
||||
↓$0 > $0
|
||||
```
|
||||
|
||||
```swift
|
||||
↓a?.b > a?.b
|
||||
```
|
||||
|
||||
```swift
|
||||
↓1 >= 1
|
||||
```
|
||||
@@ -9771,6 +9791,10 @@ expect("foo") == "foo"
|
||||
↓$0 >= $0
|
||||
```
|
||||
|
||||
```swift
|
||||
↓a?.b >= a?.b
|
||||
```
|
||||
|
||||
```swift
|
||||
↓1 < 1
|
||||
```
|
||||
@@ -9791,6 +9815,10 @@ expect("foo") == "foo"
|
||||
↓$0 < $0
|
||||
```
|
||||
|
||||
```swift
|
||||
↓a?.b < a?.b
|
||||
```
|
||||
|
||||
```swift
|
||||
↓1 <= 1
|
||||
```
|
||||
@@ -9811,6 +9839,10 @@ expect("foo") == "foo"
|
||||
↓$0 <= $0
|
||||
```
|
||||
|
||||
```swift
|
||||
↓a?.b <= a?.b
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
|
||||
@@ -46,7 +46,8 @@ public struct IdenticalOperandsRule: ConfigurationProviderRule, OptInRule, Autom
|
||||
"↓foo \(operation) foo",
|
||||
"↓foo.aProperty \(operation) foo.aProperty",
|
||||
"↓self.aProperty \(operation) self.aProperty",
|
||||
"↓$0 \(operation) $0"
|
||||
"↓$0 \(operation) $0",
|
||||
"↓a?.b \(operation) a?.b"
|
||||
]
|
||||
}
|
||||
)
|
||||
@@ -103,14 +104,14 @@ public struct IdenticalOperandsRule: ConfigurationProviderRule, OptInRule, Autom
|
||||
}
|
||||
|
||||
// Make sure both operands have same token types
|
||||
guard zip(leftOperand.tokens, rightOperand.tokens).allSatisfy({ $0.0.type == $0.1.type }) else {
|
||||
guard leftOperand.tokens.map({ $0.type }) == rightOperand.tokens.map({ $0.type }) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Make sure that every part of the operand part is equal to previous on
|
||||
guard zip(leftOperand.tokens, rightOperand.tokens).allSatisfy({
|
||||
contents.subStringWithSyntaxToken($0.0) == contents.subStringWithSyntaxToken($0.1) }) else {
|
||||
return nil
|
||||
// Make sure that every part of the operand part is equal to previous one
|
||||
guard leftOperand.tokens.map(contents.subStringWithSyntaxToken) ==
|
||||
rightOperand.tokens.map(contents.subStringWithSyntaxToken) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
guard let leftmostToken = leftOperand.tokens.first else {
|
||||
|
||||
Reference in New Issue
Block a user