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..03c494aef 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) diff --git a/Sources/Nuke/Internal/ImagePublisher.swift b/Sources/Nuke/Internal/ImagePublisher.swift index aac8a8d1d..c57e288ec 100644 --- a/Sources/Nuke/Internal/ImagePublisher.swift +++ b/Sources/Nuke/Internal/ImagePublisher.swift @@ -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..2afac208c 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) 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/Tasks/AsyncTask.swift b/Sources/Nuke/Tasks/AsyncTask.swift index 74446c23d..b79834e52 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 diff --git a/Sources/Nuke/Tasks/TaskFetchDecodedImage.swift b/Sources/Nuke/Tasks/TaskFetchDecodedImage.swift index c51c86832..3fcce71e3 100644 --- a/Sources/Nuke/Tasks/TaskFetchDecodedImage.swift +++ b/Sources/Nuke/Tasks/TaskFetchDecodedImage.swift @@ -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..105a90f28 100644 --- a/Sources/Nuke/Tasks/TaskFetchOriginalImageData.swift +++ b/Sources/Nuke/Tasks/TaskFetchOriginalImageData.swift @@ -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/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..5748a2856 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() @@ -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() diff --git a/Sources/NukeExtensions/ImageViewExtensions.swift b/Sources/NukeExtensions/ImageViewExtensions.swift index e15cf6a23..0ebed28c0 100644 --- a/Sources/NukeExtensions/ImageViewExtensions.swift +++ b/Sources/NukeExtensions/ImageViewExtensions.swift @@ -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) diff --git a/Sources/NukeUI/FetchImage.swift b/Sources/NukeUI/FetchImage.swift index dfb2f72c8..0db73c14a 100644 --- a/Sources/NukeUI/FetchImage.swift +++ b/Sources/NukeUI/FetchImage.swift @@ -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 } @@ -133,7 +133,7 @@ public final class FetchImage: ObservableObject, Identifiable { with: request, progress: { [weak self] response, completed, total in guard let self = self else { return } - if let response = response { + if let response { withTransaction(self.transaction) { self.handle(preview: response) } 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..e7180c5e8 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 } } @@ -266,10 +266,10 @@ public final class LazyImageView: _PlatformBaseView { 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 } @@ -292,7 +292,7 @@ public final class LazyImageView: _PlatformBaseView { progress: { [weak self] response, completed, total in guard let self = 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 { @@ -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() @@ -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/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)) } }