Skip to content

Commit

Permalink
Allow force casts when chainng operators
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulTaykalo committed Oct 25, 2019
1 parent 94c3f9a commit b996e0c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
32 changes: 32 additions & 0 deletions Rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -9200,6 +9200,10 @@ let num: Int? = 0
_ = num != nil && num == num?.byteSwapped
```

```swift
num == num!.byteSwapped
```

```swift
1 != 2
```
Expand Down Expand Up @@ -9257,6 +9261,10 @@ let num: Int? = 0
_ = num != nil && num != num?.byteSwapped
```

```swift
num != num!.byteSwapped
```

```swift
1 === 2
```
Expand Down Expand Up @@ -9314,6 +9322,10 @@ let num: Int? = 0
_ = num != nil && num === num?.byteSwapped
```

```swift
num === num!.byteSwapped
```

```swift
1 !== 2
```
Expand Down Expand Up @@ -9371,6 +9383,10 @@ let num: Int? = 0
_ = num != nil && num !== num?.byteSwapped
```

```swift
num !== num!.byteSwapped
```

```swift
1 > 2
```
Expand Down Expand Up @@ -9428,6 +9444,10 @@ let num: Int? = 0
_ = num != nil && num > num?.byteSwapped
```

```swift
num > num!.byteSwapped
```

```swift
1 >= 2
```
Expand Down Expand Up @@ -9485,6 +9505,10 @@ let num: Int? = 0
_ = num != nil && num >= num?.byteSwapped
```

```swift
num >= num!.byteSwapped
```

```swift
1 < 2
```
Expand Down Expand Up @@ -9542,6 +9566,10 @@ let num: Int? = 0
_ = num != nil && num < num?.byteSwapped
```

```swift
num < num!.byteSwapped
```

```swift
1 <= 2
```
Expand Down Expand Up @@ -9599,6 +9627,10 @@ let num: Int? = 0
_ = num != nil && num <= num?.byteSwapped
```

```swift
num <= num!.byteSwapped
```

```swift
func evaluate(_ mode: CommandMode) -> Result<AutoCorrectOptions, CommandantError<CommandantError<()>>>
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<AutoCorrectOptions, CommandantError<CommandantError<()>>>",
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit b996e0c

Please sign in to comment.