From d53be60729dfc8c43d40936c6fcc849c926d1df5 Mon Sep 17 00:00:00 2001 From: Luis Ferro Date: Thu, 26 Jan 2017 09:03:32 +0000 Subject: [PATCH] Swiftlint warnings breaking build When building the project in Carthage with swiftlint installed, there are 11 warnings issued that trip the build. This PR solves all but one by amending the code to correct the offending issues. The last one is fixed by adding a specific disable. This was choosen due to lack of deep knowledge of the finner details of the codebase and the fact that the affected code is underway changes on future PR that are currently WIP. --- .../CwlCatchBadInstruction.swift | 2 +- .../CwlCatchBadInstructionPOSIX.swift | 2 +- Sources/Nimble/DSL+Wait.swift | 10 +++++----- Sources/Nimble/FailureMessage.swift | 4 ++-- Sources/Nimble/Utils/Async.swift | 2 +- Tests/NimbleTests/Matchers/BeIdenticalToTest.swift | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.swift b/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.swift index 4d82f7ae2..3b6b2cd68 100644 --- a/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.swift +++ b/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.swift @@ -71,7 +71,7 @@ import Foundation var behaviors = execTypesCountTuple() var flavors = execTypesCountTuple() var currentExceptionPort: mach_port_t = 0 - var handlerThread: pthread_t? = nil + var handlerThread: pthread_t? mutating func withUnsafeMutablePointers(in block: (UnsafeMutablePointer, UnsafeMutablePointer, UnsafeMutablePointer, UnsafeMutablePointer) -> R) -> R { return masks.pointer { masksPtr in diff --git a/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstructionPOSIX.swift b/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstructionPOSIX.swift index bf3090811..34352dfd7 100644 --- a/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstructionPOSIX.swift +++ b/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstructionPOSIX.swift @@ -40,7 +40,7 @@ private func triggerLongJmp() { longjmp(&env.0, 1) } -private func sigIllHandler(code: Int32, info: UnsafeMutablePointer<__siginfo>?, uap: UnsafeMutableRawPointer?) -> Void { +private func sigIllHandler(code: Int32, info: UnsafeMutablePointer<__siginfo>?, uap: UnsafeMutableRawPointer?) { guard let context = uap?.assumingMemoryBound(to: ucontext64_t.self) else { return } // 1. Decrement the stack pointer diff --git a/Sources/Nimble/DSL+Wait.swift b/Sources/Nimble/DSL+Wait.swift index f7f373fed..4f0a8a922 100644 --- a/Sources/Nimble/DSL+Wait.swift +++ b/Sources/Nimble/DSL+Wait.swift @@ -15,7 +15,7 @@ internal class NMBWait: NSObject { timeout: TimeInterval, file: FileString = #file, line: UInt = #line, - action: @escaping (@escaping () -> Void) -> Void) -> Void { + action: @escaping (@escaping () -> Void) -> Void) { return throwableUntil(timeout: timeout, file: file, line: line) { done in action(done) } @@ -26,7 +26,7 @@ internal class NMBWait: NSObject { timeout: TimeInterval, file: FileString = #file, line: UInt = #line, - action: @escaping (@escaping () -> Void) throws -> Void) -> Void { + action: @escaping (@escaping () -> Void) throws -> Void) { let awaiter = NimbleEnvironment.activeInstance.awaiter let leeway = timeout / 2.0 let result = awaiter.performBlock { (done: @escaping (ErrorResult) -> Void) throws -> Void in @@ -71,12 +71,12 @@ internal class NMBWait: NSObject { } #if SWIFT_PACKAGE - internal class func until(_ file: FileString = #file, line: UInt = #line, action: @escaping (() -> Void) -> Void) -> Void { + internal class func until(_ file: FileString = #file, line: UInt = #line, action: @escaping (() -> Void) -> Void) { until(timeout: 1, file: file, line: line, action: action) } #else @objc(untilFile:line:action:) - internal class func until(_ file: FileString = #file, line: UInt = #line, action: @escaping (() -> Void) -> Void) -> Void { + internal class func until(_ file: FileString = #file, line: UInt = #line, action: @escaping (() -> Void) -> Void) { until(timeout: 1, file: file, line: line, action: action) } #endif @@ -93,6 +93,6 @@ internal func blockedRunLoopErrorMessageFor(_ fnName: String, leeway: TimeInterv /// /// This function manages the main run loop (`NSRunLoop.mainRunLoop()`) while this function /// is executing. Any attempts to touch the run loop may cause non-deterministic behavior. -public func waitUntil(timeout: TimeInterval = 1, file: FileString = #file, line: UInt = #line, action: @escaping (@escaping () -> Void) -> Void) -> Void { +public func waitUntil(timeout: TimeInterval = 1, file: FileString = #file, line: UInt = #line, action: @escaping (@escaping () -> Void) -> Void) { NMBWait.until(timeout: timeout, file: file, line: line, action: action) } diff --git a/Sources/Nimble/FailureMessage.swift b/Sources/Nimble/FailureMessage.swift index 24b6c8fd6..d457bf3f9 100644 --- a/Sources/Nimble/FailureMessage.swift +++ b/Sources/Nimble/FailureMessage.swift @@ -12,8 +12,8 @@ public class FailureMessage: NSObject { /// An optional message that will be appended as a new line and provides additional details /// about the failure. This message will only be visible in the issue navigator / in logs but /// not directly in the source editor since only a single line is presented there. - public var extendedMessage: String? = nil - public var userDescription: String? = nil + public var extendedMessage: String? + public var userDescription: String? public var stringValue: String { get { diff --git a/Sources/Nimble/Utils/Async.swift b/Sources/Nimble/Utils/Async.swift index 943fd30f4..89b3710d8 100644 --- a/Sources/Nimble/Utils/Async.swift +++ b/Sources/Nimble/Utils/Async.swift @@ -27,7 +27,7 @@ internal protocol WaitLock { } internal class AssertionWaitLock: WaitLock { - private var currentWaiter: WaitingInfo? = nil + private var currentWaiter: WaitingInfo? init() { } func acquireWaitingLock(_ fnName: String, file: FileString, line: UInt) { diff --git a/Tests/NimbleTests/Matchers/BeIdenticalToTest.swift b/Tests/NimbleTests/Matchers/BeIdenticalToTest.swift index 609298873..90a90b396 100644 --- a/Tests/NimbleTests/Matchers/BeIdenticalToTest.swift +++ b/Tests/NimbleTests/Matchers/BeIdenticalToTest.swift @@ -51,7 +51,7 @@ final class BeIdenticalToTest: XCTestCase, XCTestCaseProvider { func testBeAlias() { let value = NSDate() expect(value).to(be(value)) - expect(NSNumber(value:1)).toNot(be(NSString(stringLiteral: "turtles"))) + expect(NSNumber(value:1)).toNot(be(NSString(stringLiteral: "turtles"))) // swiftlint:disable:this compiler_protocol_init #if _runtime(_ObjC) expect([1]).toNot(be([1])) #else