diff --git a/.swiftlint.yml b/.swiftlint.yml index 47543c610..b9fbc059d 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -1,6 +1,3 @@ -disabled_rules: - - - included: - Sources - Tests @@ -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 @@ -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 diff --git a/Sources/Nimble/Adapters/NMBExpectation.swift b/Sources/Nimble/Adapters/NMBExpectation.swift index 32d9b60bd..bdec78987 100644 --- a/Sources/Nimble/Adapters/NMBExpectation.swift +++ b/Sources/Nimble/Adapters/NMBExpectation.swift @@ -36,13 +36,11 @@ private func from(matcher: NMBMatcher, style: ExpectationStyle) -> Predicate 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 diff --git a/Sources/Nimble/Adapters/NMBObjCMatcher.swift b/Sources/Nimble/Adapters/NMBObjCMatcher.swift index 8b8258d34..6b7ba049c 100644 --- a/Sources/Nimble/Adapters/NMBObjCMatcher.swift +++ b/Sources/Nimble/Adapters/NMBObjCMatcher.swift @@ -1,17 +1,13 @@ #if canImport(Darwin) import class Foundation.NSObject -// swiftlint:disable line_length public typealias MatcherBlock = (_ actualExpression: Expression, _ failureMessage: FailureMessage) throws -> Bool public typealias FullMatcherBlock = (_ actualExpression: Expression, _ 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) { diff --git a/Sources/Nimble/DSL+Wait.swift b/Sources/Nimble/DSL+Wait.swift index 4be4524ef..102e7d45b 100644 --- a/Sources/Nimble/DSL+Wait.swift +++ b/Sources/Nimble/DSL+Wait.swift @@ -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( diff --git a/Sources/Nimble/DSL.swift b/Sources/Nimble/DSL.swift index e481f8754..4df36a45e 100644 --- a/Sources/Nimble/DSL.swift +++ b/Sources/Nimble/DSL.swift @@ -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). diff --git a/Sources/Nimble/Expectation.swift b/Sources/Nimble/Expectation.swift index 9906c70f2..d2c57b47d 100644 --- a/Sources/Nimble/Expectation.swift +++ b/Sources/Nimble/Expectation.swift @@ -88,7 +88,6 @@ public struct Expectation { @discardableResult public func toNot(_ 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 diff --git a/Sources/Nimble/Expression.swift b/Sources/Nimble/Expression.swift index 40dde89b4..ecef26ff6 100644 --- a/Sources/Nimble/Expression.swift +++ b/Sources/Nimble/Expression.swift @@ -22,10 +22,8 @@ internal func memoizedClosure(_ 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 { - // 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 diff --git a/Sources/Nimble/FailureMessage.swift b/Sources/Nimble/FailureMessage.swift index 503b540e8..2bc57ebd4 100644 --- a/Sources/Nimble/FailureMessage.swift +++ b/Sources/Nimble/FailureMessage.swift @@ -28,7 +28,6 @@ public class FailureMessage: NSObject { } } - // swiftlint:disable:next identifier_name internal var _stringValueOverride: String? internal var hasOverriddenStringValue: Bool { return _stringValueOverride != nil diff --git a/Sources/Nimble/Matchers/Async.swift b/Sources/Nimble/Matchers/Async.swift index dc5e5eddd..6c96d89c6 100644 --- a/Sources/Nimble/Matchers/Async.swift +++ b/Sources/Nimble/Matchers/Async.swift @@ -39,7 +39,6 @@ private func async(style: ExpectationStyle, predicate: Predicate, 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) diff --git a/Sources/Nimble/Matchers/BeEmpty.swift b/Sources/Nimble/Matchers/BeEmpty.swift index 3e890d500..4036471db 100644 --- a/Sources/Nimble/Matchers/BeEmpty.swift +++ b/Sources/Nimble/Matchers/BeEmpty.swift @@ -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, diff --git a/Sources/Nimble/Matchers/Contain.swift b/Sources/Nimble/Matchers/Contain.swift index c7fc15b1c..38d1dab50 100644 --- a/Sources/Nimble/Matchers/Contain.swift +++ b/Sources/Nimble/Matchers/Contain.swift @@ -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 { diff --git a/Sources/Nimble/Matchers/MatcherProtocols.swift b/Sources/Nimble/Matchers/MatcherProtocols.swift index 720ced01c..53512348a 100644 --- a/Sources/Nimble/Matchers/MatcherProtocols.swift +++ b/Sources/Nimble/Matchers/MatcherProtocols.swift @@ -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 {} diff --git a/Sources/Nimble/Matchers/Predicate.swift b/Sources/Nimble/Matchers/Predicate.swift index fa0128f47..423d2b830 100644 --- a/Sources/Nimble/Matchers/Predicate.swift +++ b/Sources/Nimble/Matchers/Predicate.swift @@ -169,7 +169,6 @@ extension Predicate { /// Compatibility layer for old Matcher API, deprecated. /// Emulates the MatcherFunc API internal static func _fromDeprecatedClosure(_ matcher: @escaping (Expression, FailureMessage) throws -> Bool) -> Predicate { - // swiftlint:disable:previous identifier_name return Predicate { actual in let failureMessage = FailureMessage() let result = try matcher(actual, failureMessage) diff --git a/Sources/Nimble/Matchers/SatisfyAllOf.swift b/Sources/Nimble/Matchers/SatisfyAllOf.swift index 7fbeeef69..fd7ae1f69 100644 --- a/Sources/Nimble/Matchers/SatisfyAllOf.swift +++ b/Sources/Nimble/Matchers/SatisfyAllOf.swift @@ -63,7 +63,6 @@ extension NMBPredicate { for matcher in matchers { let elementEvaluator = Predicate { 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() diff --git a/Sources/Nimble/Matchers/SatisfyAnyOf.swift b/Sources/Nimble/Matchers/SatisfyAnyOf.swift index 44615dce7..037ccc938 100644 --- a/Sources/Nimble/Matchers/SatisfyAnyOf.swift +++ b/Sources/Nimble/Matchers/SatisfyAnyOf.swift @@ -73,7 +73,6 @@ extension NMBPredicate { for matcher in matchers { let elementEvaluator = Predicate { 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()