Skip to content

Commit

Permalink
Simplify regex (#3145)
Browse files Browse the repository at this point in the history
* Simplify regex

`\w` already includes `_`

* Fix test
  • Loading branch information
jpsim authored Mar 18, 2020
1 parent 302f377 commit c201ae4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private extension SwiftLintFile {
func rangedAndSortedUnusedImports(of unusedImports: [String], contents: NSString) -> [(String, NSRange)] {
return unusedImports
.compactMap { module in
match(pattern: "^(@[\\w_]+ +)?import +\(module)\\b.*?\n").first.map { (module, $0.0) }
match(pattern: "^(@\\w+ +)?import +\(module)\\b.*?\n").first.map { (module, $0.0) }
}
.sorted(by: { $0.1.location < $1.1.location })
}
Expand Down
2 changes: 2 additions & 0 deletions Tests/SwiftLintFrameworkTests/LinterCacheTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ class LinterCacheTests: XCTestCase {
func testDetectSwiftVersion() {
#if compiler(>=5.2.0)
let version = "5.2.0"
#elseif compiler(>=5.1.5)
let version = "5.1.5"
#elseif compiler(>=5.1.4)
let version = "5.1.4"
#elseif compiler(>=5.1.3)
Expand Down

0 comments on commit c201ae4

Please sign in to comment.