Skip to content

Commit

Permalink
Merge pull request #858 from Quick/tweak-swiftlint-configurations
Browse files Browse the repository at this point in the history
Tweak SwiftLint configurations
  • Loading branch information
ikesyo authored Feb 6, 2021
2 parents 0c6ff90 + 908854b commit dc99c94
Show file tree
Hide file tree
Showing 15 changed files with 14 additions and 27 deletions.
21 changes: 13 additions & 8 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
disabled_rules:
-

included:
- Sources
- Tests
Expand All @@ -11,12 +8,11 @@ excluded:
- Tests/NimbleTests/XCTestManifests.swift
- Tests/NimbleTests/Helpers/XCTestCaseProvider.swift

trailing_comma:
mandatory_comma: true
disabled_rules:
-

line_length:
ignores_comments: true
ignores_function_declarations: true
opt_in_rules:
- yoda_condition

identifier_name:
max_length: 50
Expand All @@ -30,3 +26,12 @@ identifier_name:
- to
allowed_symbols:
- _

line_length:
warning: 160
error: 240
ignores_comments: true
ignores_function_declarations: true

trailing_comma:
mandatory_comma: true
2 changes: 0 additions & 2 deletions Sources/Nimble/Adapters/NMBExpectation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ private func from(matcher: NMBMatcher, style: ExpectationStyle) -> Predicate<NSO

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

@objc public init(actualBlock: @escaping () -> NSObject?, negative: Bool, file: FileString, line: UInt) {
self._actualBlock = actualBlock
Expand Down
4 changes: 0 additions & 4 deletions Sources/Nimble/Adapters/NMBObjCMatcher.swift
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
#if canImport(Darwin)
import class Foundation.NSObject

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

@available(*, deprecated, message: "Use NMBPredicate instead")
public class NMBObjCMatcher: NSObject, NMBMatcher {
// swiftlint:disable identifier_name
let _match: MatcherBlock
let _doesNotMatch: MatcherBlock
// swiftlint:enable identifier_name
let canMatchNil: Bool

public init(canMatchNil: Bool, matcher: @escaping MatcherBlock, notMatcher: @escaping MatcherBlock) {
Expand Down
1 change: 0 additions & 1 deletion Sources/Nimble/DSL+Wait.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ internal class NMBWait: NSObject {
action: @escaping (@escaping () -> Void) throws -> Void) {
let awaiter = NimbleEnvironment.activeInstance.awaiter
let leeway = timeout.divided
// swiftlint:disable:next line_length
let result = awaiter.performBlock(file: file, line: line) { (done: @escaping (ErrorResult) -> Void) throws -> Void in
DispatchQueue.main.async {
let capture = NMBExceptionCapture(
Expand Down
1 change: 0 additions & 1 deletion Sources/Nimble/DSL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ internal func nimblePrecondition(
}

internal func internalError(_ msg: String, file: FileString = #file, line: UInt = #line) -> Never {
// swiftlint:disable line_length
fatalError(
"""
Nimble Bug Found: \(msg) at \(file):\(line).
Expand Down
1 change: 0 additions & 1 deletion Sources/Nimble/Expectation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ public struct Expectation<T> {
@discardableResult
public func toNot<U>(_ matcher: U, description: String? = nil) -> Self
where U: Matcher, U.ValueType == T {
// swiftlint:disable:next line_length
let (pass, msg) = expressionDoesNotMatch(expression, matcher: matcher, toNot: "to not", description: description)
verify(pass, msg)
return self
Expand Down
2 changes: 0 additions & 2 deletions Sources/Nimble/Expression.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ internal func memoizedClosure<T>(_ closure: @escaping () throws -> T) -> (Bool)
/// This provides a common consumable API for matchers to utilize to allow
/// Nimble to change internals to how the captured closure is managed.
public struct Expression<T> {
// swiftlint:disable identifier_name
internal let _expression: (Bool) throws -> T?
internal let _withoutCaching: Bool
// swiftlint:enable identifier_name
public let location: SourceLocation
public let isClosure: Bool

Expand Down
1 change: 0 additions & 1 deletion Sources/Nimble/FailureMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public class FailureMessage: NSObject {
}
}

// swiftlint:disable:next identifier_name
internal var _stringValueOverride: String?
internal var hasOverriddenStringValue: Bool {
return _stringValueOverride != nil
Expand Down
1 change: 0 additions & 1 deletion Sources/Nimble/Matchers/Async.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ private func async<T>(style: ExpectationStyle, predicate: Predicate<T>, timeout:
case let .raisedException(exception):
return PredicateResult(status: .fail, message: .fail("unexpected exception raised: \(exception)"))
case .blockedRunLoop:
// swiftlint:disable:next line_length
let message = lastPredicateResult?.message.appended(message: " (timed out, but main run loop was unresponsive).") ??
.fail("main run loop was unresponsive")
return PredicateResult(status: .fail, message: message)
Expand Down
1 change: 0 additions & 1 deletion Sources/Nimble/Matchers/BeEmpty.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ extension NMBPredicate {
let expr = Expression(expression: ({ value }), location: location)
return try beEmpty().satisfies(expr).toObjectiveC()
} else if let actualValue = actualValue {
// swiftlint:disable:next line_length
let badTypeErrorMsg = "be empty (only works for NSArrays, NSSets, NSIndexSets, NSDictionaries, NSHashTables, and NSStrings)"
return NMBPredicateResult(
status: NMBPredicateStatus.fail,
Expand Down
1 change: 0 additions & 1 deletion Sources/Nimble/Matchers/Contain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ extension NMBPredicate {
let message: ExpectationMessage
if actualValue != nil {
message = ExpectationMessage.expectedActualValueTo(
// swiftlint:disable:next line_length
"contain <\(arrayAsString(expected))> (only works for NSArrays, NSSets, NSHashTables, and NSStrings)"
)
} else {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Nimble/Matchers/MatcherProtocols.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public protocol NMBContainer {
#if canImport(Darwin)
// swiftlint:disable:next todo
// FIXME: NSHashTable can not conform to NMBContainer since swift-DEVELOPMENT-SNAPSHOT-2016-04-25-a
//extension NSHashTable : NMBContainer {} // Corelibs Foundation does not include this class yet
// extension NSHashTable : NMBContainer {} // Corelibs Foundation does not include this class yet
#endif

extension NSArray: NMBContainer {}
Expand Down
1 change: 0 additions & 1 deletion Sources/Nimble/Matchers/Predicate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ extension Predicate {
/// Compatibility layer for old Matcher API, deprecated.
/// Emulates the MatcherFunc API
internal static func _fromDeprecatedClosure(_ matcher: @escaping (Expression<T>, FailureMessage) throws -> Bool) -> Predicate {
// swiftlint:disable:previous identifier_name
return Predicate { actual in
let failureMessage = FailureMessage()
let result = try matcher(actual, failureMessage)
Expand Down
1 change: 0 additions & 1 deletion Sources/Nimble/Matchers/SatisfyAllOf.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ extension NMBPredicate {
for matcher in matchers {
let elementEvaluator = Predicate<NSObject> { expression in
if let predicate = matcher as? NMBPredicate {
// swiftlint:disable:next line_length
return predicate.satisfies({ try expression.evaluate() }, location: actualExpression.location).toSwift()
} else {
let failureMessage = FailureMessage()
Expand Down
1 change: 0 additions & 1 deletion Sources/Nimble/Matchers/SatisfyAnyOf.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ extension NMBPredicate {
for matcher in matchers {
let elementEvaluator = Predicate<NSObject> { expression in
if let predicate = matcher as? NMBPredicate {
// swiftlint:disable:next line_length
return predicate.satisfies({ try expression.evaluate() }, location: actualExpression.location).toSwift()
} else {
let failureMessage = FailureMessage()
Expand Down

0 comments on commit dc99c94

Please sign in to comment.