You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
func index(of element: Element) -> AnyIndex? method is deprecated in Xcode 10.2.
Its method should migrate to func firstIndex(of element: Element) -> AnyIndex?.
Since I migrated my code, SwiftLint warnings about SortedFirstLastRule.
Complete output when running SwiftLint, including the stack trace and command used
$ echo"keys.sorted().firstIndex(of: idx)"| swiftlint lint --no-cache --use-stdin --enable-all-rules
Loading configuration from '.swiftlint.yml'<nopath>:1:1: warning: Min or Max over Sorted First or Last Violation: Prefer using `min()` or `max()` over `sorted().first` or `sorted().last` (sorted_first_last)Done linting! Found 1 violation, 0 serious in 1 file.
And also lastIndex(of:)
$ echo"keys.sorted().lastIndex(of: idx)"| swiftlint lint --no-cache --use-stdin --enable-all-rules
Loading configuration from '.swiftlint.yml'<nopath>:1:1: warning: Min or Max over Sorted First or Last Violation: Prefer using `min()` or `max()` over `sorted().first` or `sorted().last` (sorted_first_last)Done linting! Found 1 violation, 0 serious in 1 file.
Environment
SwiftLint version (run swiftlint version to be sure)? 0.31.0
Installation method used (Homebrew, CocoaPods, building from source, etc)? Homebrew
Paste your configuration file:
opt_in_rules:
- sorted_first_last
Are you using nested configurations?
If so, paste their relative paths and respective contents.
No
Which Xcode version are you using (check xcode-select -p)? 10.2
Do you have a sample that shows the issue? Run echo "[string here]" | swiftlint lint --no-cache --use-stdin --enable-all-rules
to quickly test if your example is really demonstrating the issue. If your example is more
complex, you can use swiftlint lint --path [file here] --no-cache --enable-all-rules.
// This triggers a violation:
keys.sorted().firstIndex(of: idx)
keys.sorted().lastIndex(of: idx)
The text was updated successfully, but these errors were encountered:
r-plus
changed the title
False positive on SortedFirstLastRule (sorted_first_last) with firstIndex(of:) or lastIndex(of:) method.
False positive on SortedFirstLastRule (sorted_first_last) with firstIndex(of:) and lastIndex(of:) method.
Apr 1, 2019
r-plus
added a commit
to r-plus/SwiftLint
that referenced
this issue
Apr 1, 2019
r-plus
changed the title
False positive on SortedFirstLastRule (sorted_first_last) with firstIndex(of:) and lastIndex(of:) method.
False positive on SortedFirstLastRule (sorted_first_last) with firstIndex(of:), firstIndex(where:), lastIndex(of:) and lastIndex(where:) method.
Apr 2, 2019
New Issue Checklist
Describe the bug
func index(of element: Element) -> AnyIndex?
method is deprecated in Xcode 10.2.Its method should migrate to
func firstIndex(of element: Element) -> AnyIndex?
.Since I migrated my code, SwiftLint warnings about SortedFirstLastRule.
Complete output when running SwiftLint, including the stack trace and command used
And also
lastIndex(of:)
Environment
swiftlint version
to be sure)? 0.31.0If so, paste their relative paths and respective contents.
No
xcode-select -p
)? 10.2echo "[string here]" | swiftlint lint --no-cache --use-stdin --enable-all-rules
to quickly test if your example is really demonstrating the issue. If your example is more
complex, you can use
swiftlint lint --path [file here] --no-cache --enable-all-rules
.The text was updated successfully, but these errors were encountered: