clean code

This commit is contained in:
Lukas Schmidt 2015-09-18 18:09:35 +02:00
parent 6cffbc2404
commit 198f24c684
2 changed files with 15 additions and 17 deletions

View File

@ -66,7 +66,6 @@ class AbstractSocketTest: XCTestCase {
if let expection = expection {
expection.fulfill()
}
}
AbstractSocketTest.socket.on(finalTestname + "Return", callback: didGetEmit)

View File

@ -29,8 +29,8 @@ internal class SwiftRegex: NSObject, BooleanType {
NSRegularExpressionOptions.DotMatchesLineSeparators)
swiftRegexCache[pattern] = regex
self.regex = regex
} catch let error1 as NSError {
SwiftRegex.failure("Error in pattern: \(pattern) - \(error1)")
} catch let error as NSError {
SwiftRegex.failure("Error in pattern: \(pattern) - \(error)")
self.regex = NSRegularExpression()
}
}
@ -46,7 +46,7 @@ internal class SwiftRegex: NSObject, BooleanType {
}
private final func substring(range: NSRange) -> String? {
if ( range.location != NSNotFound ) {
if range.location != NSNotFound {
return (target as NSString).substringWithRange(range)
} else {
return nil
@ -70,8 +70,10 @@ internal class SwiftRegex: NSObject, BooleanType {
NSMatchingOptions.WithoutAnchoringBounds, range: targetRange))
}
private func groupsForMatch(match: NSTextCheckingResult!) -> [String]? {
if match != nil {
private func groupsForMatch(match: NSTextCheckingResult?) -> [String]? {
guard let match = match else {
return nil
}
var groups = [String]()
for groupno in 0...regex.numberOfCaptureGroups {
if let group = substring(match.rangeAtIndex(groupno)) {
@ -81,9 +83,6 @@ internal class SwiftRegex: NSObject, BooleanType {
}
}
return groups
} else {
return nil
}
}
subscript(groupno: Int) -> String? {