Skip to content

Commit

Permalink
Add some non-triggering examples to SortedFirstLastRule
Browse files Browse the repository at this point in the history
  • Loading branch information
r-plus committed Apr 2, 2019
1 parent c7a1cc1 commit 72dc428
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
24 changes: 24 additions & 0 deletions Rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -17486,6 +17486,30 @@ let message = messages.sorted(byKeyPath: #keyPath(Message.timestamp)).last
let message = messages.sorted(byKeyPath: "timestamp", ascending: false).first
```

```swift
myList.sorted().firstIndex(of: key)
```

```swift
myList.sorted().lastIndex(of: key)
```

```swift
myList.sorted().firstIndex(where: someFunction)
```

```swift
myList.sorted().lastIndex(where: someFunction)
```

```swift
myList.sorted().firstIndex { $0 == key }
```

```swift
myList.sorted().lastIndex { $0 == key }
```

</details>
<details>
<summary>Triggering Examples</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ public struct SortedFirstLastRule: CallPairRule, OptInRule, ConfigurationProvide
"let max = myList.max()\n",
"let max = myList.max(by: { $0 < $1 })\n",
"let message = messages.sorted(byKeyPath: #keyPath(Message.timestamp)).last",
"let message = messages.sorted(byKeyPath: \"timestamp\", ascending: false).first"
"let message = messages.sorted(byKeyPath: \"timestamp\", ascending: false).first",
"myList.sorted().firstIndex(of: key)",
"myList.sorted().lastIndex(of: key)",
"myList.sorted().firstIndex(where: someFunction)",
"myList.sorted().lastIndex(where: someFunction)",
"myList.sorted().firstIndex { $0 == key }",
"myList.sorted().lastIndex { $0 == key }"
],
triggeringExamples: [
"↓myList.sorted().first\n",
Expand Down

0 comments on commit 72dc428

Please sign in to comment.