clean code
This commit is contained in:
parent
6cffbc2404
commit
198f24c684
@ -66,7 +66,6 @@ class AbstractSocketTest: XCTestCase {
|
|||||||
if let expection = expection {
|
if let expection = expection {
|
||||||
expection.fulfill()
|
expection.fulfill()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractSocketTest.socket.on(finalTestname + "Return", callback: didGetEmit)
|
AbstractSocketTest.socket.on(finalTestname + "Return", callback: didGetEmit)
|
||||||
|
|||||||
@ -29,8 +29,8 @@ internal class SwiftRegex: NSObject, BooleanType {
|
|||||||
NSRegularExpressionOptions.DotMatchesLineSeparators)
|
NSRegularExpressionOptions.DotMatchesLineSeparators)
|
||||||
swiftRegexCache[pattern] = regex
|
swiftRegexCache[pattern] = regex
|
||||||
self.regex = regex
|
self.regex = regex
|
||||||
} catch let error1 as NSError {
|
} catch let error as NSError {
|
||||||
SwiftRegex.failure("Error in pattern: \(pattern) - \(error1)")
|
SwiftRegex.failure("Error in pattern: \(pattern) - \(error)")
|
||||||
self.regex = NSRegularExpression()
|
self.regex = NSRegularExpression()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@ internal class SwiftRegex: NSObject, BooleanType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final func substring(range: NSRange) -> String? {
|
private final func substring(range: NSRange) -> String? {
|
||||||
if ( range.location != NSNotFound ) {
|
if range.location != NSNotFound {
|
||||||
return (target as NSString).substringWithRange(range)
|
return (target as NSString).substringWithRange(range)
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
@ -70,8 +70,10 @@ internal class SwiftRegex: NSObject, BooleanType {
|
|||||||
NSMatchingOptions.WithoutAnchoringBounds, range: targetRange))
|
NSMatchingOptions.WithoutAnchoringBounds, range: targetRange))
|
||||||
}
|
}
|
||||||
|
|
||||||
private func groupsForMatch(match: NSTextCheckingResult!) -> [String]? {
|
private func groupsForMatch(match: NSTextCheckingResult?) -> [String]? {
|
||||||
if match != nil {
|
guard let match = match else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
var groups = [String]()
|
var groups = [String]()
|
||||||
for groupno in 0...regex.numberOfCaptureGroups {
|
for groupno in 0...regex.numberOfCaptureGroups {
|
||||||
if let group = substring(match.rangeAtIndex(groupno)) {
|
if let group = substring(match.rangeAtIndex(groupno)) {
|
||||||
@ -81,9 +83,6 @@ internal class SwiftRegex: NSObject, BooleanType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return groups
|
return groups
|
||||||
} else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
subscript(groupno: Int) -> String? {
|
subscript(groupno: Int) -> String? {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user