Skip to content

Commit 471f58e

Browse files
authored
Merge pull request #563 from Quick/swiftlint-identifier_name
[SwiftLint] Remove identifier_name from disabled_rules
2 parents 61847ca + 951feea commit 471f58e

File tree

14 files changed

+56
-21
lines changed

14 files changed

+56
-21
lines changed

.swiftlint.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
disabled_rules:
22
- todo
3-
- variable_name
43
- force_try
54

65
included:
@@ -18,3 +17,16 @@ trailing_comma:
1817
line_length:
1918
ignores_comments: true
2019
ignores_function_declarations: true
20+
21+
identifier_name:
22+
max_length: 50
23+
excluded:
24+
- x
25+
- l
26+
- r
27+
- e
28+
- n1
29+
- n2
30+
- to
31+
allowed_symbols:
32+
- _

Sources/Nimble/Adapters/AdapterProtocols.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ public protocol AssertionHandler {
1313
///
1414
/// @see AssertionHandler
1515
public var NimbleAssertionHandler: AssertionHandler = { () -> AssertionHandler in
16+
// swiftlint:disable:previous identifier_name
1617
return isXCTestAvailable() ? NimbleXCTestHandler() : NimbleXCTestUnavailableHandler()
1718
}()

Sources/Nimble/Adapters/NMBExpectation.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ internal struct ObjCMatcherWrapper: Matcher {
3030

3131
// Equivalent to Expectation, but for Nimble's Objective-C interface
3232
public class NMBExpectation: NSObject {
33+
// swiftlint:disable identifier_name
3334
internal let _actualBlock: () -> NSObject?
3435
internal var _negative: Bool
3536
internal let _file: FileString
3637
internal let _line: UInt
3738
internal var _timeout: TimeInterval = 1.0
39+
// swiftlint:enable identifier_name
3840

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

Sources/Nimble/Adapters/NMBObjCMatcher.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ public typealias FullMatcherBlock = (_ actualExpression: Expression<NSObject>, _
88
// swiftlint:enable line_length
99

1010
public class NMBObjCMatcher: NSObject, NMBMatcher {
11+
// swiftlint:disable identifier_name
1112
let _match: MatcherBlock
1213
let _doesNotMatch: MatcherBlock
14+
// swiftlint:enable identifier_name
1315
let canMatchNil: Bool
1416

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

Sources/Nimble/DSL.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ internal func nimblePrecondition(
4444
let result = expr()
4545
if !result {
4646
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
47-
let e = NSException(
47+
let exception = NSException(
4848
name: NSExceptionName(name()),
4949
reason: message(),
50-
userInfo: nil)
51-
e.raise()
50+
userInfo: nil
51+
)
52+
exception.raise()
5253
#else
5354
preconditionFailure("\(name()) - \(message())", file: file, line: line)
5455
#endif

Sources/Nimble/ExpectationMessage.swift

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public indirect enum ExpectationMessage {
7575
}
7676

7777
internal func visitLeafs(_ f: (ExpectationMessage) -> ExpectationMessage) -> ExpectationMessage {
78+
// swiftlint:disable:previous identifier_name
7879
switch self {
7980
case .fail, .expectedTo, .expectedActualValueTo, .expectedCustomValueTo:
8081
return f(self)
@@ -90,6 +91,7 @@ public indirect enum ExpectationMessage {
9091
/// Replaces a primary expectation with one returned by f. Preserves all composite expectations
9192
/// that were built upon it (aka - all appended(message:) and appended(details:).
9293
public func replacedExpectation(_ f: @escaping (ExpectationMessage) -> ExpectationMessage) -> ExpectationMessage {
94+
// swiftlint:disable:previous identifier_name
9395
func walk(_ msg: ExpectationMessage) -> ExpectationMessage {
9496
switch msg {
9597
case .fail, .expectedTo, .expectedActualValueTo, .expectedCustomValueTo:
@@ -181,28 +183,28 @@ public indirect enum ExpectationMessage {
181183

182184
extension FailureMessage {
183185
internal func toExpectationMessage() -> ExpectationMessage {
184-
let defaultMsg = FailureMessage()
185-
if expected != defaultMsg.expected || _stringValueOverride != nil {
186+
let defaultMessage = FailureMessage()
187+
if expected != defaultMessage.expected || _stringValueOverride != nil {
186188
return .fail(stringValue)
187189
}
188190

189-
var msg: ExpectationMessage = .fail(userDescription ?? "")
191+
var message: ExpectationMessage = .fail(userDescription ?? "")
190192
if actualValue != "" && actualValue != nil {
191-
msg = .expectedCustomValueTo(postfixMessage, actualValue ?? "")
192-
} else if postfixMessage != defaultMsg.postfixMessage {
193+
message = .expectedCustomValueTo(postfixMessage, actualValue ?? "")
194+
} else if postfixMessage != defaultMessage.postfixMessage {
193195
if actualValue == nil {
194-
msg = .expectedTo(postfixMessage)
196+
message = .expectedTo(postfixMessage)
195197
} else {
196-
msg = .expectedActualValueTo(postfixMessage)
198+
message = .expectedActualValueTo(postfixMessage)
197199
}
198200
}
199-
if postfixActual != defaultMsg.postfixActual {
200-
msg = .appends(msg, postfixActual)
201+
if postfixActual != defaultMessage.postfixActual {
202+
message = .appends(message, postfixActual)
201203
}
202-
if let m = extendedMessage {
203-
msg = .details(msg, m)
204+
if let extended = extendedMessage {
205+
message = .details(message, extended)
204206
}
205-
return msg
207+
return message
206208
}
207209
}
208210

Sources/Nimble/Expression.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ internal func memoizedClosure<T>(_ closure: @escaping () throws -> T) -> (Bool)
2424
/// This provides a common consumable API for matchers to utilize to allow
2525
/// Nimble to change internals to how the captured closure is managed.
2626
public struct Expression<T> {
27+
// swiftlint:disable identifier_name
2728
internal let _expression: (Bool) throws -> T?
2829
internal let _withoutCaching: Bool
30+
// swiftlint:enable identifier_name
2931
public let location: SourceLocation
3032
public let isClosure: Bool
3133

Sources/Nimble/FailureMessage.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class FailureMessage: NSObject {
2828
}
2929
}
3030

31+
// swiftlint:disable:next identifier_name
3132
internal var _stringValueOverride: String?
3233
internal var hasOverriddenStringValue: Bool {
3334
return _stringValueOverride != nil

Sources/Nimble/Matchers/BeCloseTo.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Foundation
22

3+
// swiftlint:disable:next identifier_name
34
public let DefaultDelta = 0.0001
45

56
internal func isCloseTo(_ actualValue: NMBDoubleConvertible?,
@@ -36,8 +37,10 @@ public func beCloseTo(_ expectedValue: NMBDoubleConvertible, within delta: Doubl
3637

3738
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
3839
public class NMBObjCBeCloseToMatcher: NSObject, NMBMatcher {
40+
// swiftlint:disable identifier_name
3941
var _expected: NSNumber
4042
var _delta: CDouble
43+
// swiftlint:enable identifier_name
4144
init(expected: NSNumber, within: CDouble) {
4245
_expected = expected
4346
_delta = within
@@ -98,14 +101,17 @@ public func beCloseTo(_ expectedValues: [Double], within delta: Double = Default
98101

99102
infix operator : ComparisonPrecedence
100103

104+
// swiftlint:disable:next identifier_name
101105
public func (lhs: Expectation<[Double]>, rhs: [Double]) {
102106
lhs.to(beCloseTo(rhs))
103107
}
104108

109+
// swiftlint:disable:next identifier_name
105110
public func (lhs: Expectation<NMBDoubleConvertible>, rhs: NMBDoubleConvertible) {
106111
lhs.to(beCloseTo(rhs))
107112
}
108113

114+
// swiftlint:disable:next identifier_name
109115
public func (lhs: Expectation<NMBDoubleConvertible>, rhs: (expected: NMBDoubleConvertible, delta: Double)) {
110116
lhs.to(beCloseTo(rhs.expected, within: rhs.delta))
111117
}
@@ -121,6 +127,7 @@ precedencegroup PlusMinusOperatorPrecedence {
121127
}
122128

123129
infix operator ± : PlusMinusOperatorPrecedence
130+
// swiftlint:disable:next identifier_name
124131
public func ±(lhs: NMBDoubleConvertible, rhs: Double) -> (expected: NMBDoubleConvertible, delta: Double) {
125132
return (expected: lhs, delta: rhs)
126133
}

Sources/Nimble/Matchers/PostNotification.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ internal class NotificationCollector {
1616

1717
func startObserving() {
1818
// swiftlint:disable:next line_length
19-
self.token = self.notificationCenter.addObserver(forName: nil, object: nil, queue: nil, using: { [weak self] n in
19+
self.token = self.notificationCenter.addObserver(forName: nil, object: nil, queue: nil) { [weak self] notification in
2020
// linux-swift gets confused by .append(n)
21-
self?.observedNotifications.append(n)
22-
})
21+
self?.observedNotifications.append(notification)
22+
}
2323
}
2424

2525
deinit {

0 commit comments

Comments
 (0)