diff --git a/Documentation/Nuke.docc/Customization/ImageFormats/supported-image-formats.md b/Documentation/Nuke.docc/Customization/ImageFormats/supported-image-formats.md index 598624091..cde331141 100644 --- a/Documentation/Nuke.docc/Customization/ImageFormats/supported-image-formats.md +++ b/Documentation/Nuke.docc/Customization/ImageFormats/supported-image-formats.md @@ -137,7 +137,7 @@ ImageDecoderRegistry.shared.register { context in let url = URL(string: "https://upload.wikimedia.org/wikipedia/commons/9/9d/Swift_logo.svg") ImagePipeline.shared.loadImage(with: url) { [weak self] result in - guard let self = self, let data = try? result.get().container.data else { + guard let self, let data = try? result.get().container.data else { return } // You can render an image using whatever size you want, vector! diff --git a/Sources/Nuke/Caching/Cache.swift b/Sources/Nuke/Caching/Cache.swift index 67a50275b..b35a18994 100644 --- a/Sources/Nuke/Caching/Cache.swift +++ b/Sources/Nuke/Caching/Cache.swift @@ -202,7 +202,7 @@ final class Cache: @unchecked Sendable { let cost: Int let expiration: Date? var isExpired: Bool { - guard let expiration = expiration else { + guard let expiration else { return false } return expiration.timeIntervalSinceNow < 0 diff --git a/Sources/Nuke/Decoding/AssetType.swift b/Sources/Nuke/Decoding/AssetType.swift index 51b6cfbd9..d1173d975 100644 --- a/Sources/Nuke/Decoding/AssetType.swift +++ b/Sources/Nuke/Decoding/AssetType.swift @@ -53,7 +53,7 @@ extension AssetType { return false } return zip(numbers.indices, numbers).allSatisfy { index, number in - guard let number = number else { return true } + guard let number else { return true } guard (index + offset) < data.count else { return false } return data[index + offset] == number } diff --git a/Sources/Nuke/Decoding/ImageDecoders+Default.swift b/Sources/Nuke/Decoding/ImageDecoders+Default.swift index 83f0048dd..9cafe07db 100644 --- a/Sources/Nuke/Decoding/ImageDecoders+Default.swift +++ b/Sources/Nuke/Decoding/ImageDecoders+Default.swift @@ -51,7 +51,7 @@ extension ImageDecoders { defer { lock.unlock() } func makeImage() -> PlatformImage? { - if let thumbnail = self.thumbnail { + if let thumbnail { return makeThumbnail(data: data, options: thumbnail) } return ImageDecoders.Default._decode(data, scale: scale) diff --git a/Sources/Nuke/Internal/Graphics.swift b/Sources/Nuke/Internal/Graphics.swift index e49e252d1..4e06db882 100644 --- a/Sources/Nuke/Internal/Graphics.swift +++ b/Sources/Nuke/Internal/Graphics.swift @@ -107,7 +107,7 @@ struct ImageProcessingExtensions { ctx.clip() ctx.draw(cgImage, in: CGRect(origin: CGPoint.zero, size: cgImage.size)) - if let border = border { + if let border { ctx.setStrokeColor(border.color.cgColor) ctx.addPath(path) ctx.setLineWidth(border.width) @@ -131,7 +131,7 @@ extension PlatformImage { /// /// - parameter drawRect: `nil` by default. If `nil` will use the canvas rect. func draw(inCanvasWithSize canvasSize: CGSize, drawRect: CGRect? = nil) -> PlatformImage? { - guard let cgImage = cgImage else { + guard let cgImage else { return nil } guard let ctx = CGContext.make(cgImage, size: canvasSize) else { @@ -151,7 +151,7 @@ extension PlatformImage { return preparingForDisplay() } #endif - guard let cgImage = cgImage else { + guard let cgImage else { return nil } return draw(inCanvasWithSize: cgImage.size, drawRect: CGRect(origin: .zero, size: cgImage.size)) diff --git a/Sources/Nuke/Internal/ImagePublisher.swift b/Sources/Nuke/Internal/ImagePublisher.swift index aac8a8d1d..775e363db 100644 --- a/Sources/Nuke/Internal/ImagePublisher.swift +++ b/Sources/Nuke/Internal/ImagePublisher.swift @@ -47,7 +47,7 @@ private final class ImageSubscription: Subscription where S: Subscriber, S: S func request(_ demand: Subscribers.Demand) { guard demand > 0 else { return } - guard let subscriber = subscriber else { return } + guard let subscriber else { return } if let image = pipeline.cache[request] { _ = subscriber.receive(ImageResponse(container: image, request: request, cacheType: .memory)) @@ -62,7 +62,7 @@ private final class ImageSubscription: Subscription where S: Subscriber, S: S with: request, queue: nil, progress: { response, _, _ in - if let response = response { + if let response { // Send progressively decoded image (if enabled and if any) _ = subscriber.receive(response) } diff --git a/Sources/Nuke/Internal/LinkedList.swift b/Sources/Nuke/Internal/LinkedList.swift index 7474fd9fb..2f33ab63d 100644 --- a/Sources/Nuke/Internal/LinkedList.swift +++ b/Sources/Nuke/Internal/LinkedList.swift @@ -30,7 +30,7 @@ final class LinkedList { /// Adds a node to the end of the list. func append(_ node: Node) { - if let last = last { + if let last { last.next = node node.previous = last self.last = node diff --git a/Sources/Nuke/Pipeline/ImagePipeline.swift b/Sources/Nuke/Pipeline/ImagePipeline.swift index 315ac563a..34af0cacf 100644 --- a/Sources/Nuke/Pipeline/ImagePipeline.swift +++ b/Sources/Nuke/Pipeline/ImagePipeline.swift @@ -169,7 +169,7 @@ public final class ImagePipeline: @unchecked Sendable { continuation.resume(throwing: CancellationError()) } self.startImageTask(task, progress: { response, progress in - if let response = response { + if let response { context?.previews?.yield(response) } else { context?.progress?.yield(progress) @@ -308,7 +308,7 @@ public final class ImagePipeline: @unchecked Sendable { tasks[task] = makeTaskLoadImage(for: task.request) .subscribe(priority: task.priority.taskPriority, subscriber: task) { [weak self, weak task] event in - guard let self = self, let task = task else { return } + guard let self, let task else { return } if event.isCompleted { self.tasks[task] = nil @@ -425,7 +425,7 @@ public final class ImagePipeline: @unchecked Sendable { tasks[task] = makeTaskLoadData(for: task.request) .subscribe(priority: task.priority.taskPriority, subscriber: task) { [weak self, weak task] event in - guard let self = self, let task = task else { return } + guard let self, let task else { return } if event.isCompleted { self.tasks[task] = nil diff --git a/Sources/Nuke/Pipeline/ImagePipelineConfiguration.swift b/Sources/Nuke/Pipeline/ImagePipelineConfiguration.swift index 4872cb81a..59e1dcdde 100644 --- a/Sources/Nuke/Pipeline/ImagePipelineConfiguration.swift +++ b/Sources/Nuke/Pipeline/ImagePipelineConfiguration.swift @@ -201,7 +201,7 @@ extension ImagePipeline { config.dataLoader = dataLoader let dataCache = try? DataCache(name: name) - if let sizeLimit = sizeLimit { + if let sizeLimit { dataCache?.sizeLimit = sizeLimit } config.dataCache = dataCache diff --git a/Sources/Nuke/Prefetching/ImagePrefetcher.swift b/Sources/Nuke/Prefetching/ImagePrefetcher.swift index 93e5cbf72..88cb4ed60 100644 --- a/Sources/Nuke/Prefetching/ImagePrefetcher.swift +++ b/Sources/Nuke/Prefetching/ImagePrefetcher.swift @@ -128,7 +128,7 @@ public final class ImagePrefetcher: @unchecked Sendable { } let task = Task(request: request, key: key) task.operation = queue.add { [weak self] finish in - guard let self = self else { return finish() } + guard let self else { return finish() } self.loadImage(task: task, finish: finish) } tasks[key] = task diff --git a/Sources/Nuke/Tasks/AsyncTask.swift b/Sources/Nuke/Tasks/AsyncTask.swift index 74446c23d..5d55151da 100644 --- a/Sources/Nuke/Tasks/AsyncTask.swift +++ b/Sources/Nuke/Tasks/AsyncTask.swift @@ -174,7 +174,7 @@ class AsyncTask: AsyncTaskSubscriptionDelegate } inlineSubscription?.closure(event) - if let subscriptions = subscriptions { + if let subscriptions { for subscription in subscriptions.values { subscription.closure(event) } @@ -203,7 +203,7 @@ class AsyncTask: AsyncTaskSubscriptionDelegate // MARK: - Priority private func updatePriority(suggestedPriority: TaskPriority?) { - if let suggestedPriority = suggestedPriority, suggestedPriority >= priority { + if let suggestedPriority, suggestedPriority >= priority { // No need to recompute, won't go higher than that priority = suggestedPriority return @@ -212,7 +212,7 @@ class AsyncTask: AsyncTaskSubscriptionDelegate var newPriority = inlineSubscription?.priority // Same as subscriptions.map { $0?.priority }.max() but without allocating // any memory for redundant arrays - if let subscriptions = subscriptions { + if let subscriptions { for subscription in subscriptions.values { if newPriority == nil { newPriority = subscription.priority @@ -243,7 +243,7 @@ extension AsyncTask { /// - notes: Returns `nil` if the task is already disposed. func subscribe(_ task: AsyncTask, onValue: @escaping (Value, Bool) -> Void) -> TaskSubscription? { subscribe(subscriber: task) { [weak task] event in - guard let task = task else { return } + guard let task else { return } switch event { case let .value(value, isCompleted): onValue(value, isCompleted) diff --git a/Sources/Nuke/Tasks/OperationTask.swift b/Sources/Nuke/Tasks/OperationTask.swift index f50d0d23a..fd3da5331 100644 --- a/Sources/Nuke/Tasks/OperationTask.swift +++ b/Sources/Nuke/Tasks/OperationTask.swift @@ -18,7 +18,7 @@ final class OperationTask: AsyncTask { override func start() { operation = queue.add { [weak self] in - guard let self = self else { return } + guard let self else { return } let result = Result(catching: { try self.process() }) self.pipeline.queue.async { switch result { diff --git a/Sources/Nuke/Tasks/TaskFetchDecodedImage.swift b/Sources/Nuke/Tasks/TaskFetchDecodedImage.swift index c51c86832..04f4fecbe 100644 --- a/Sources/Nuke/Tasks/TaskFetchDecodedImage.swift +++ b/Sources/Nuke/Tasks/TaskFetchDecodedImage.swift @@ -50,7 +50,7 @@ final class TaskFetchDecodedImage: ImagePipelineTask { didFinishDecoding(decoder: decoder, context: context, result: decode()) } else { operation = pipeline.configuration.imageDecodingQueue.add { [weak self] in - guard let self = self else { return } + guard let self else { return } let result = decode() self.pipeline.queue.async { @@ -74,7 +74,7 @@ final class TaskFetchDecodedImage: ImagePipelineTask { // Lazily creates decoding for task private func getDecoder(for context: ImageDecodingContext) -> (any ImageDecoding)? { // Return the existing processor in case it has already been created. - if let decoder = self.decoder { + if let decoder { return decoder } let decoder = pipeline.delegate.imageDecoder(for: context, pipeline: pipeline) diff --git a/Sources/Nuke/Tasks/TaskFetchOriginalImageData.swift b/Sources/Nuke/Tasks/TaskFetchOriginalImageData.swift index 32985ac4e..c4e1dc37d 100644 --- a/Sources/Nuke/Tasks/TaskFetchOriginalImageData.swift +++ b/Sources/Nuke/Tasks/TaskFetchOriginalImageData.swift @@ -23,7 +23,7 @@ final class TaskFetchOriginalImageData: ImagePipelineTask<(Data, URLResponse?)> // Rate limiter is synchronized on pipeline's queue. Delayed work is // executed asynchronously also on the same queue. rateLimiter.execute { [weak self] in - guard let self = self, !self.isDisposed else { + guard let self, !self.isDisposed else { return false } self.loadData(urlRequest: urlRequest) @@ -41,7 +41,7 @@ final class TaskFetchOriginalImageData: ImagePipelineTask<(Data, URLResponse?)> // Wrap data request in an operation to limit the maximum number of // concurrent data tasks. operation = pipeline.configuration.dataLoadingQueue.add { [weak self] finish in - guard let self = self else { + guard let self else { return finish() } self.pipeline.queue.async { @@ -72,13 +72,13 @@ final class TaskFetchOriginalImageData: ImagePipelineTask<(Data, URLResponse?)> let dataLoader = pipeline.delegate.dataLoader(for: request, pipeline: pipeline) let dataTask = dataLoader.loadData(with: urlRequest, didReceiveData: { [weak self] data, response in - guard let self = self else { return } + guard let self else { return } self.pipeline.queue.async { self.dataTask(didReceiveData: data, response: response) } }, completion: { [weak self] error in finish() // Finish the operation! - guard let self = self else { return } + guard let self else { return } signpost(self, "LoadImageData", .end, "Finished with size \(Formatter.bytes(self.data.count))") self.pipeline.queue.async { self.dataTaskDidFinish(error: error) @@ -86,7 +86,7 @@ final class TaskFetchOriginalImageData: ImagePipelineTask<(Data, URLResponse?)> }) onCancelled = { [weak self] in - guard let self = self else { return } + guard let self else { return } signpost(self, "LoadImageData", .end, "Cancelled") dataTask.cancel() @@ -100,7 +100,7 @@ final class TaskFetchOriginalImageData: ImagePipelineTask<(Data, URLResponse?)> // Check if this is the first response. if urlResponse == nil { // See if the server confirmed that the resumable data can be used - if let resumableData = resumableData, ResumableData.isResumedResponse(response) { + if let resumableData, ResumableData.isResumedResponse(response) { data = resumableData.data resumedDataCount = Int64(resumableData.data.count) signpost(self, "LoadImageData", .event, "Resumed with data \(Formatter.bytes(resumedDataCount))") @@ -128,7 +128,7 @@ final class TaskFetchOriginalImageData: ImagePipelineTask<(Data, URLResponse?)> } private func dataTaskDidFinish(error: Swift.Error?) { - if let error = error { + if let error { tryToSaveResumableData() send(error: .dataLoadingFailed(error: error)) return diff --git a/Sources/Nuke/Tasks/TaskFetchWithPublisher.swift b/Sources/Nuke/Tasks/TaskFetchWithPublisher.swift index 45cce2b11..713b15dbc 100644 --- a/Sources/Nuke/Tasks/TaskFetchWithPublisher.swift +++ b/Sources/Nuke/Tasks/TaskFetchWithPublisher.swift @@ -16,7 +16,7 @@ final class TaskFetchWithPublisher: ImagePipelineTask<(Data, URLResponse?)> { // Wrap data request in an operation to limit the maximum number of // concurrent data tasks. operation = pipeline.configuration.dataLoadingQueue.add { [weak self] finish in - guard let self = self else { + guard let self else { return finish() } self.pipeline.queue.async { @@ -39,12 +39,12 @@ final class TaskFetchWithPublisher: ImagePipelineTask<(Data, URLResponse?)> { let cancellable = publisher.sink(receiveCompletion: { [weak self] result in finish() // Finish the operation! - guard let self = self else { return } + guard let self else { return } self.pipeline.queue.async { self.dataTaskDidFinish(result) } }, receiveValue: { [weak self] data in - guard let self = self else { return } + guard let self else { return } self.pipeline.queue.async { self.data.append(data) } diff --git a/Sources/Nuke/Tasks/TaskLoadData.swift b/Sources/Nuke/Tasks/TaskLoadData.swift index 6d8d00db9..e7e113ccd 100644 --- a/Sources/Nuke/Tasks/TaskLoadData.swift +++ b/Sources/Nuke/Tasks/TaskLoadData.swift @@ -22,7 +22,7 @@ final class TaskLoadData: ImagePipelineTask<(Data, URLResponse?)> { pipeline.cache.cachedData(for: request) } pipeline.queue.async { - if let data = data { + if let data { self.send(value: (data, nil), isCompleted: true) } else { self.loadData() diff --git a/Sources/Nuke/Tasks/TaskLoadImage.swift b/Sources/Nuke/Tasks/TaskLoadImage.swift index 24e2c9552..56fc61dc7 100644 --- a/Sources/Nuke/Tasks/TaskLoadImage.swift +++ b/Sources/Nuke/Tasks/TaskLoadImage.swift @@ -40,7 +40,7 @@ final class TaskLoadImage: ImagePipelineTask { pipeline.cache.cachedData(for: request) } pipeline.queue.async { - if let data = data { + if let data { self.didReceiveCachedData(data) } else { self.fetchImage() @@ -67,7 +67,7 @@ final class TaskLoadImage: ImagePipelineTask { didDecodeCachedData(decode()) } else { operation = pipeline.configuration.imageDecodingQueue.add { [weak self] in - guard let self = self else { return } + guard let self else { return } let response = decode() self.pipeline.queue.async { self.didDecodeCachedData(response) @@ -77,7 +77,7 @@ final class TaskLoadImage: ImagePipelineTask { } private func didDecodeCachedData(_ response: ImageResponse?) { - if let response = response { + if let response { decompressImage(response, isCompleted: true, isFromDiskCache: true) } else { fetchImage() @@ -161,7 +161,7 @@ final class TaskLoadImage: ImagePipelineTask { return response } }).subscribe(priority: priority) { [weak self] event in - guard let self = self else { return } + guard let self else { return } if event.isCompleted { self.dependency2 = nil } @@ -196,7 +196,7 @@ final class TaskLoadImage: ImagePipelineTask { guard !isDisposed else { return } operation = pipeline.configuration.imageDecompressingQueue.add { [weak self] in - guard let self = self else { return } + guard let self else { return } let response = signpost("DecompressImage", isCompleted ? "FinalImage" : "ProgressiveImage") { self.pipeline.delegate.decompress(response: response, request: self.request, pipeline: self.pipeline) @@ -240,7 +240,7 @@ final class TaskLoadImage: ImagePipelineTask { let encoder = pipeline.delegate.imageEncoder(for: context, pipeline: pipeline) let key = pipeline.cache.makeDataCacheKey(for: request) pipeline.configuration.imageEncodingQueue.addOperation { [weak pipeline, request] in - guard let pipeline = pipeline else { return } + guard let pipeline else { return } let encodedData = signpost("EncodeImage") { encoder.encode(response.container, context: context) } diff --git a/Sources/NukeExtensions/ImageViewExtensions.swift b/Sources/NukeExtensions/ImageViewExtensions.swift index e15cf6a23..8e2fa2d99 100644 --- a/Sources/NukeExtensions/ImageViewExtensions.swift +++ b/Sources/NukeExtensions/ImageViewExtensions.swift @@ -238,7 +238,7 @@ private final class ImageViewController { ) -> ImageTask? { cancelOutstandingTask() - guard let imageView = imageView else { + guard let imageView else { return nil } @@ -254,7 +254,7 @@ private final class ImageViewController { } // Handle a scenario where request is `nil` (in the same way as a failure) - guard var request = request else { + guard var request else { if options.isPrepareForReuseEnabled { imageView.nuke_display(image: nil, data: nil) } @@ -286,7 +286,7 @@ private final class ImageViewController { } task = pipeline.loadImage(with: request, queue: .main, progress: { [weak self] response, completedCount, totalCount in - if let response = response, options.isProgressiveRenderingEnabled { + if let response, options.isProgressiveRenderingEnabled { self?.handle(partialImage: response) } progress?(response, completedCount, totalCount) @@ -323,7 +323,7 @@ private final class ImageViewController { #if os(iOS) || os(tvOS) || os(macOS) || os(visionOS) private func display(_ image: ImageContainer, _ isFromMemory: Bool, _ response: ImageLoadingOptions.ResponseType) { - guard let imageView = imageView else { + guard let imageView else { return } @@ -371,7 +371,7 @@ extension ImageViewController { #if os(iOS) || os(tvOS) || os(visionOS) private func runFadeInTransition(image: ImageContainer, params: ImageLoadingOptions.Transition.Parameters, response: ImageLoadingOptions.ResponseType) { - guard let imageView = imageView else { + guard let imageView else { return } @@ -385,7 +385,7 @@ extension ImageViewController { } private func runSimpleFadeIn(image: ImageContainer, params: ImageLoadingOptions.Transition.Parameters) { - guard let imageView = imageView else { + guard let imageView else { return } diff --git a/Sources/NukeUI/FetchImage.swift b/Sources/NukeUI/FetchImage.swift index dfb2f72c8..e0fc9025c 100644 --- a/Sources/NukeUI/FetchImage.swift +++ b/Sources/NukeUI/FetchImage.swift @@ -104,7 +104,7 @@ public final class FetchImage: ObservableObject, Identifiable { reset() - guard var request = request else { + guard var request else { handle(result: .failure(ImagePipeline.Error.imageRequestMissing)) return } @@ -112,7 +112,7 @@ public final class FetchImage: ObservableObject, Identifiable { if !processors.isEmpty && request.processors.isEmpty { request.processors = processors } - if let priority = self.priority { + if let priority { request.priority = priority } @@ -132,8 +132,8 @@ public final class FetchImage: ObservableObject, Identifiable { let task = pipeline.loadImage( with: request, progress: { [weak self] response, completed, total in - guard let self = self else { return } - if let response = response { + guard let self else { return } + if let response { withTransaction(self.transaction) { self.handle(preview: response) } @@ -143,7 +143,7 @@ public final class FetchImage: ObservableObject, Identifiable { } }, completion: { [weak self] result in - guard let self = self else { return } + guard let self else { return } withTransaction(self.transaction) { self.handle(result: result.mapError { $0 }) } @@ -205,7 +205,7 @@ public final class FetchImage: ObservableObject, Identifiable { // Not using `first()` because it should support progressive decoding isLoading = true cancellable = publisher.sink(receiveCompletion: { [weak self] completion in - guard let self = self else { return } + guard let self else { return } self.isLoading = false switch completion { case .finished: @@ -216,7 +216,7 @@ public final class FetchImage: ObservableObject, Identifiable { self.result = .failure(error) } }, receiveValue: { [weak self] response in - guard let self = self else { return } + guard let self else { return } self.lastResponse = response self.imageContainer = response.container }) diff --git a/Sources/NukeUI/LazyImage.swift b/Sources/NukeUI/LazyImage.swift index 452d5f220..3d4f8d3f5 100644 --- a/Sources/NukeUI/LazyImage.swift +++ b/Sources/NukeUI/LazyImage.swift @@ -134,7 +134,7 @@ public struct LazyImage: View { public var body: some View { ZStack { - if let makeContent = makeContent { + if let makeContent { makeContent(viewModel) } else { makeDefaultContent(for: viewModel) diff --git a/Sources/NukeUI/LazyImageView.swift b/Sources/NukeUI/LazyImageView.swift index 48ee27b85..3abaa5340 100644 --- a/Sources/NukeUI/LazyImageView.swift +++ b/Sources/NukeUI/LazyImageView.swift @@ -125,7 +125,7 @@ public final class LazyImageView: _PlatformBaseView { /// dynamically. `nil` by default. public var priority: ImageRequest.Priority? { didSet { - if let priority = self.priority { + if let priority { imageTask?.priority = priority } } @@ -261,15 +261,15 @@ public final class LazyImageView: _PlatformBaseView { isResetNeeded = true } - guard var request = request else { + guard var request else { handle(result: .failure(ImagePipeline.Error.imageRequestMissing), isSync: true) return } - if let processors = self.processors, !processors.isEmpty, request.processors.isEmpty { + if let processors, !processors.isEmpty, request.processors.isEmpty { request.processors = processors } - if let priority = self.priority { + if let priority { request.priority = priority } @@ -290,9 +290,9 @@ public final class LazyImageView: _PlatformBaseView { with: request, queue: .main, progress: { [weak self] response, completed, total in - guard let self = self else { return } + guard let self else { return } let progress = ImageTask.Progress(completed: completed, total: total) - if let response = response { + if let response { self.handle(preview: response) self.onPreview?(response) } else { @@ -358,7 +358,7 @@ public final class LazyImageView: _PlatformBaseView { } private func setPlaceholderImage(_ placeholderImage: PlatformImage?) { - guard let placeholderImage = placeholderImage else { + guard let placeholderImage else { placeholderView = nil return } @@ -366,10 +366,10 @@ public final class LazyImageView: _PlatformBaseView { } private func setPlaceholderView(_ oldView: _PlatformBaseView?, _ newView: _PlatformBaseView?) { - if let oldView = oldView { + if let oldView { oldView.removeFromSuperview() } - if let newView = newView { + if let newView { newView.isHidden = !imageView.isHidden insertSubview(newView, at: 0) setNeedsUpdateConstraints() @@ -393,7 +393,7 @@ public final class LazyImageView: _PlatformBaseView { } private func setFailureImage(_ failureImage: PlatformImage?) { - guard let failureImage = failureImage else { + guard let failureImage else { failureView = nil return } @@ -401,10 +401,10 @@ public final class LazyImageView: _PlatformBaseView { } private func setFailureView(_ oldView: _PlatformBaseView?, _ newView: _PlatformBaseView?) { - if let oldView = oldView { + if let oldView { oldView.removeFromSuperview() } - if let newView = newView { + if let newView { newView.isHidden = true insertSubview(newView, at: 0) setNeedsUpdateConstraints() diff --git a/Sources/NukeVideo/VideoPlayerView.swift b/Sources/NukeVideo/VideoPlayerView.swift index 26637aed5..d1bef4e7f 100644 --- a/Sources/NukeVideo/VideoPlayerView.swift +++ b/Sources/NukeVideo/VideoPlayerView.swift @@ -130,7 +130,7 @@ public final class VideoPlayerView: _PlatformBaseView { } public func play() { - guard let asset = asset else { + guard let asset else { return } diff --git a/Tests/CombineExtensions.swift b/Tests/CombineExtensions.swift index 2163df592..99ef50517 100644 --- a/Tests/CombineExtensions.swift +++ b/Tests/CombineExtensions.swift @@ -31,7 +31,7 @@ extension Subscriptions { } func start(_ closure: @escaping (AnySubscriber) -> Void) { - if let subscriber = subscriber { + if let subscriber { closure(AnySubscriber(subscriber)) } } diff --git a/Tests/NukeTests/ImagePipelineTests/ImagePipelineProgressiveDecodingTests.swift b/Tests/NukeTests/ImagePipelineTests/ImagePipelineProgressiveDecodingTests.swift index 888e8f463..a67fa1007 100644 --- a/Tests/NukeTests/ImagePipelineTests/ImagePipelineProgressiveDecodingTests.swift +++ b/Tests/NukeTests/ImagePipelineTests/ImagePipelineProgressiveDecodingTests.swift @@ -316,7 +316,7 @@ class ImagePipelineProgressiveDecodingTests: XCTestCase { // applies the remaining processors and delivers it let previewDelivered = self.expectation(description: "previewDelivered") pipeline.loadImage(with: request) { response, _, _ in - guard let response = response else { + guard let response else { return XCTFail() } XCTAssertEqual(response.image.nk_test_processorIDs, ["2"]) @@ -339,7 +339,7 @@ class ImagePipelineProgressiveDecodingTests: XCTestCase { // applies the remaining processors and delivers it let previewDelivered = self.expectation(description: "previewDelivered") pipeline.loadImage(with: request) { response, _, _ in - guard let response = response else { + guard let response else { return } XCTAssertTrue(response.container.isPreview)