Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SwiftLint] fix unused optional binding vaiolation #417

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/Nimble/Matchers/BeginWith.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ extension NMBObjCMatcher {
public class func beginWithMatcher(_ expected: Any) -> NMBObjCMatcher {
return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in
let actual = try! actualExpression.evaluate()
if let _ = actual as? String {
if (actual as? String) != nil {
let expr = actualExpression.cast { $0 as? String }
return try! beginWith(expected as! String).matches(expr, failureMessage: failureMessage)
} else {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Nimble/Matchers/EndWith.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ extension NMBObjCMatcher {
public class func endWithMatcher(_ expected: Any) -> NMBObjCMatcher {
return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in
let actual = try! actualExpression.evaluate()
if let _ = actual as? String {
if (actual as? String) != nil {
let expr = actualExpression.cast { $0 as? String }
return try! endWith(expected as! String).matches(expr, failureMessage: failureMessage)
} else {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Nimble/Matchers/RaisesException.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ internal func setFailureMessageForException(
if let userInfo = userInfo {
failureMessage.postfixMessage += " with userInfo <\(userInfo)>"
}
if let _ = closure {
if closure != nil {
failureMessage.postfixMessage += " that satisfies block"
}
if named == nil && reason == nil && userInfo == nil && closure == nil {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Nimble/Utils/Errors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal func setFailureMessageForError<T: Error>(
} else if errorType != nil || closure != nil {
failureMessage.postfixMessage += " from type <\(T.self)>"
}
if let _ = closure {
if closure != nil {
failureMessage.postfixMessage += " that satisfies block"
}
if error == nil && errorType == nil && closure == nil {
Expand Down Expand Up @@ -101,7 +101,7 @@ internal func setFailureMessageForError(
closure: ((Error) -> Void)?) {
failureMessage.postfixMessage = "throw error"

if let _ = closure {
if closure != nil {
failureMessage.postfixMessage += " that satisfies block"
} else {
failureMessage.postfixMessage = "throw any error"
Expand Down