Skip to content

Commit

Permalink
Merge pull request Quick#562 from Quick/swiftlint-force_cast
Browse files Browse the repository at this point in the history
[SwiftLint] Remove force_cast from disabled_rules
wongzigii authored Jul 5, 2018

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
2 parents 3fd8e34 + 196dc15 commit 50fa589
Showing 5 changed files with 5 additions and 1 deletion.
1 change: 0 additions & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@ disabled_rules:
- todo
- variable_name
- force_try
- force_cast

included:
- Sources
1 change: 1 addition & 0 deletions Sources/Nimble/Matchers/BeginWith.swift
Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@ extension NMBObjCMatcher {
let actual = try! actualExpression.evaluate()
if (actual as? String) != nil {
let expr = actualExpression.cast { $0 as? String }
// swiftlint:disable:next force_cast
return try! beginWith(expected as! String).matches(expr, failureMessage: failureMessage)
} else {
let expr = actualExpression.cast { $0 as? NMBOrderedCollection }
1 change: 1 addition & 0 deletions Sources/Nimble/Matchers/Contain.swift
Original file line number Diff line number Diff line change
@@ -81,6 +81,7 @@ extension NMBObjCMatcher {
return try! contain(expectedOptionals).matches(expr, failureMessage: failureMessage)
} else if let value = actualValue as? NSString {
let expr = Expression(expression: ({ value as String }), location: location)
// swiftlint:disable:next force_cast
return try! contain(expected as! [String]).matches(expr, failureMessage: failureMessage)
} else if actualValue != nil {
// swiftlint:disable:next line_length
1 change: 1 addition & 0 deletions Sources/Nimble/Matchers/EndWith.swift
Original file line number Diff line number Diff line change
@@ -61,6 +61,7 @@ extension NMBObjCMatcher {
let actual = try! actualExpression.evaluate()
if (actual as? String) != nil {
let expr = actualExpression.cast { $0 as? String }
// swiftlint:disable:next force_cast
return try! endWith(expected as! String).matches(expr, failureMessage: failureMessage)
} else {
let expr = actualExpression.cast { $0 as? NMBOrderedCollection }
2 changes: 2 additions & 0 deletions Sources/Nimble/Matchers/MatcherProtocols.swift
Original file line number Diff line number Diff line change
@@ -144,11 +144,13 @@ public protocol NMBComparable {

extension NSNumber: NMBComparable {
public func NMB_compare(_ otherObject: NMBComparable!) -> ComparisonResult {
// swiftlint:disable:next force_cast
return compare(otherObject as! NSNumber)
}
}
extension NSString: NMBComparable {
public func NMB_compare(_ otherObject: NMBComparable!) -> ComparisonResult {
// swiftlint:disable:next force_cast
return compare(otherObject as! String)
}
}

0 comments on commit 50fa589

Please sign in to comment.