diff --git a/Rules.md b/Rules.md index 0e3790291d..48120822ce 100644 --- a/Rules.md +++ b/Rules.md @@ -9200,6 +9200,10 @@ let num: Int? = 0 _ = num != nil && num == num?.byteSwapped ``` +```swift +num == num!.byteSwapped +``` + ```swift 1 != 2 ``` @@ -9257,6 +9261,10 @@ let num: Int? = 0 _ = num != nil && num != num?.byteSwapped ``` +```swift +num != num!.byteSwapped +``` + ```swift 1 === 2 ``` @@ -9314,6 +9322,10 @@ let num: Int? = 0 _ = num != nil && num === num?.byteSwapped ``` +```swift +num === num!.byteSwapped +``` + ```swift 1 !== 2 ``` @@ -9371,6 +9383,10 @@ let num: Int? = 0 _ = num != nil && num !== num?.byteSwapped ``` +```swift +num !== num!.byteSwapped +``` + ```swift 1 > 2 ``` @@ -9428,6 +9444,10 @@ let num: Int? = 0 _ = num != nil && num > num?.byteSwapped ``` +```swift +num > num!.byteSwapped +``` + ```swift 1 >= 2 ``` @@ -9485,6 +9505,10 @@ let num: Int? = 0 _ = num != nil && num >= num?.byteSwapped ``` +```swift +num >= num!.byteSwapped +``` + ```swift 1 < 2 ``` @@ -9542,6 +9566,10 @@ let num: Int? = 0 _ = num != nil && num < num?.byteSwapped ``` +```swift +num < num!.byteSwapped +``` + ```swift 1 <= 2 ``` @@ -9599,6 +9627,10 @@ let num: Int? = 0 _ = num != nil && num <= num?.byteSwapped ``` +```swift +num <= num!.byteSwapped +``` + ```swift func evaluate(_ mode: CommandMode) -> Result>> ``` diff --git a/Source/SwiftLintFramework/Rules/Lint/IdenticalOperandsRule.swift b/Source/SwiftLintFramework/Rules/Lint/IdenticalOperandsRule.swift index 8f0a4fdd5a..8930f9ed67 100644 --- a/Source/SwiftLintFramework/Rules/Lint/IdenticalOperandsRule.swift +++ b/Source/SwiftLintFramework/Rules/Lint/IdenticalOperandsRule.swift @@ -31,7 +31,8 @@ public struct IdenticalOperandsRule: ConfigurationProviderRule, OptInRule, Autom """ let num: Int? = 0 _ = num != nil && num \(operation) num?.byteSwapped - """ + """, + "num \(operation) num!.byteSwapped" ] } + [ "func evaluate(_ mode: CommandMode) -> Result>>", @@ -181,7 +182,7 @@ private extension NSString { } func isDotOrOptionalChainingBetweenTokens(_ startToken: SyntaxToken, _ endToken: SyntaxToken) -> Bool { - return isRegexBetweenTokens(startToken, "\\??\\.", endToken) + return isRegexBetweenTokens(startToken, "[\\?!]?\\.", endToken) } func isNilCoalecingOperatorBetweenTokens(_ startToken: SyntaxToken, _ endToken: SyntaxToken) -> Bool {