Skip to content

Commit 908854b

Browse files
committed
Tweak SwiftLint configurations
1 parent 0c6ff90 commit 908854b

15 files changed

+14
-27
lines changed

.swiftlint.yml

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
disabled_rules:
2-
-
3-
41
included:
52
- Sources
63
- Tests
@@ -11,12 +8,11 @@ excluded:
118
- Tests/NimbleTests/XCTestManifests.swift
129
- Tests/NimbleTests/Helpers/XCTestCaseProvider.swift
1310

14-
trailing_comma:
15-
mandatory_comma: true
11+
disabled_rules:
12+
-
1613

17-
line_length:
18-
ignores_comments: true
19-
ignores_function_declarations: true
14+
opt_in_rules:
15+
- yoda_condition
2016

2117
identifier_name:
2218
max_length: 50
@@ -30,3 +26,12 @@ identifier_name:
3026
- to
3127
allowed_symbols:
3228
- _
29+
30+
line_length:
31+
warning: 160
32+
error: 240
33+
ignores_comments: true
34+
ignores_function_declarations: true
35+
36+
trailing_comma:
37+
mandatory_comma: true

Sources/Nimble/Adapters/NMBExpectation.swift

-2
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@ private func from(matcher: NMBMatcher, style: ExpectationStyle) -> Predicate<NSO
3636

3737
// Equivalent to Expectation, but for Nimble's Objective-C interface
3838
public class NMBExpectation: NSObject {
39-
// swiftlint:disable identifier_name
4039
internal let _actualBlock: () -> NSObject?
4140
internal var _negative: Bool
4241
internal let _file: FileString
4342
internal let _line: UInt
4443
internal var _timeout: DispatchTimeInterval = .seconds(1)
45-
// swiftlint:enable identifier_name
4644

4745
@objc public init(actualBlock: @escaping () -> NSObject?, negative: Bool, file: FileString, line: UInt) {
4846
self._actualBlock = actualBlock

Sources/Nimble/Adapters/NMBObjCMatcher.swift

-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
#if canImport(Darwin)
22
import class Foundation.NSObject
33

4-
// swiftlint:disable line_length
54
public typealias MatcherBlock = (_ actualExpression: Expression<NSObject>, _ failureMessage: FailureMessage) throws -> Bool
65
public typealias FullMatcherBlock = (_ actualExpression: Expression<NSObject>, _ failureMessage: FailureMessage, _ shouldNotMatch: Bool) throws -> Bool
7-
// swiftlint:enable line_length
86

97
@available(*, deprecated, message: "Use NMBPredicate instead")
108
public class NMBObjCMatcher: NSObject, NMBMatcher {
11-
// swiftlint:disable identifier_name
129
let _match: MatcherBlock
1310
let _doesNotMatch: MatcherBlock
14-
// swiftlint:enable identifier_name
1511
let canMatchNil: Bool
1612

1713
public init(canMatchNil: Bool, matcher: @escaping MatcherBlock, notMatcher: @escaping MatcherBlock) {

Sources/Nimble/DSL+Wait.swift

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ internal class NMBWait: NSObject {
4444
action: @escaping (@escaping () -> Void) throws -> Void) {
4545
let awaiter = NimbleEnvironment.activeInstance.awaiter
4646
let leeway = timeout.divided
47-
// swiftlint:disable:next line_length
4847
let result = awaiter.performBlock(file: file, line: line) { (done: @escaping (ErrorResult) -> Void) throws -> Void in
4948
DispatchQueue.main.async {
5049
let capture = NMBExceptionCapture(

Sources/Nimble/DSL.swift

-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ internal func nimblePrecondition(
6565
}
6666

6767
internal func internalError(_ msg: String, file: FileString = #file, line: UInt = #line) -> Never {
68-
// swiftlint:disable line_length
6968
fatalError(
7069
"""
7170
Nimble Bug Found: \(msg) at \(file):\(line).

Sources/Nimble/Expectation.swift

-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ public struct Expectation<T> {
8888
@discardableResult
8989
public func toNot<U>(_ matcher: U, description: String? = nil) -> Self
9090
where U: Matcher, U.ValueType == T {
91-
// swiftlint:disable:next line_length
9291
let (pass, msg) = expressionDoesNotMatch(expression, matcher: matcher, toNot: "to not", description: description)
9392
verify(pass, msg)
9493
return self

Sources/Nimble/Expression.swift

-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ internal func memoizedClosure<T>(_ closure: @escaping () throws -> T) -> (Bool)
2222
/// This provides a common consumable API for matchers to utilize to allow
2323
/// Nimble to change internals to how the captured closure is managed.
2424
public struct Expression<T> {
25-
// swiftlint:disable identifier_name
2625
internal let _expression: (Bool) throws -> T?
2726
internal let _withoutCaching: Bool
28-
// swiftlint:enable identifier_name
2927
public let location: SourceLocation
3028
public let isClosure: Bool
3129

Sources/Nimble/FailureMessage.swift

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public class FailureMessage: NSObject {
2828
}
2929
}
3030

31-
// swiftlint:disable:next identifier_name
3231
internal var _stringValueOverride: String?
3332
internal var hasOverriddenStringValue: Bool {
3433
return _stringValueOverride != nil

Sources/Nimble/Matchers/Async.swift

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ private func async<T>(style: ExpectationStyle, predicate: Predicate<T>, timeout:
3939
case let .raisedException(exception):
4040
return PredicateResult(status: .fail, message: .fail("unexpected exception raised: \(exception)"))
4141
case .blockedRunLoop:
42-
// swiftlint:disable:next line_length
4342
let message = lastPredicateResult?.message.appended(message: " (timed out, but main run loop was unresponsive).") ??
4443
.fail("main run loop was unresponsive")
4544
return PredicateResult(status: .fail, message: message)

Sources/Nimble/Matchers/BeEmpty.swift

-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ extension NMBPredicate {
9191
let expr = Expression(expression: ({ value }), location: location)
9292
return try beEmpty().satisfies(expr).toObjectiveC()
9393
} else if let actualValue = actualValue {
94-
// swiftlint:disable:next line_length
9594
let badTypeErrorMsg = "be empty (only works for NSArrays, NSSets, NSIndexSets, NSDictionaries, NSHashTables, and NSStrings)"
9695
return NMBPredicateResult(
9796
status: NMBPredicateStatus.fail,

Sources/Nimble/Matchers/Contain.swift

-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ extension NMBPredicate {
123123
let message: ExpectationMessage
124124
if actualValue != nil {
125125
message = ExpectationMessage.expectedActualValueTo(
126-
// swiftlint:disable:next line_length
127126
"contain <\(arrayAsString(expected))> (only works for NSArrays, NSSets, NSHashTables, and NSStrings)"
128127
)
129128
} else {

Sources/Nimble/Matchers/MatcherProtocols.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public protocol NMBContainer {
4545
#if canImport(Darwin)
4646
// swiftlint:disable:next todo
4747
// FIXME: NSHashTable can not conform to NMBContainer since swift-DEVELOPMENT-SNAPSHOT-2016-04-25-a
48-
//extension NSHashTable : NMBContainer {} // Corelibs Foundation does not include this class yet
48+
// extension NSHashTable : NMBContainer {} // Corelibs Foundation does not include this class yet
4949
#endif
5050

5151
extension NSArray: NMBContainer {}

Sources/Nimble/Matchers/Predicate.swift

-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ extension Predicate {
169169
/// Compatibility layer for old Matcher API, deprecated.
170170
/// Emulates the MatcherFunc API
171171
internal static func _fromDeprecatedClosure(_ matcher: @escaping (Expression<T>, FailureMessage) throws -> Bool) -> Predicate {
172-
// swiftlint:disable:previous identifier_name
173172
return Predicate { actual in
174173
let failureMessage = FailureMessage()
175174
let result = try matcher(actual, failureMessage)

Sources/Nimble/Matchers/SatisfyAllOf.swift

-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ extension NMBPredicate {
6363
for matcher in matchers {
6464
let elementEvaluator = Predicate<NSObject> { expression in
6565
if let predicate = matcher as? NMBPredicate {
66-
// swiftlint:disable:next line_length
6766
return predicate.satisfies({ try expression.evaluate() }, location: actualExpression.location).toSwift()
6867
} else {
6968
let failureMessage = FailureMessage()

Sources/Nimble/Matchers/SatisfyAnyOf.swift

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ extension NMBPredicate {
7373
for matcher in matchers {
7474
let elementEvaluator = Predicate<NSObject> { expression in
7575
if let predicate = matcher as? NMBPredicate {
76-
// swiftlint:disable:next line_length
7776
return predicate.satisfies({ try expression.evaluate() }, location: actualExpression.location).toSwift()
7877
} else {
7978
let failureMessage = FailureMessage()

0 commit comments

Comments
 (0)