From d03f49a096a9aecab4468db2beb7de2044b69451 Mon Sep 17 00:00:00 2001 From: Cal Stephens Date: Thu, 3 Nov 2022 08:10:20 -0700 Subject: [PATCH] Update to latest version of Airbnb style formatter plugin (#1797) --- Rakefile | 2 +- .../Animations/CALayer+addAnimation.swift | 9 +-- .../Animations/ShapeAnimation.swift | 6 +- .../Layers/CALayer+setupLayerHierarchy.swift | 4 +- .../CoreAnimation/Layers/PreCompLayer.swift | 3 +- .../CoreAnimation/Layers/ShapeLayer.swift | 7 ++- .../CoreAnimation/ValueProviderStore.swift | 3 +- .../CompLayers/MaskContainerLayer.swift | 2 +- .../CompLayers/PreCompositionLayer.swift | 4 +- .../MainThreadAnimationLayer.swift | 6 +- .../ValueProviders/GroupInterpolator.swift | 4 +- .../Nodes/ModifierNodes/TrimPathNode.swift | 2 +- .../Renderables/StrokeRenderer.swift | 2 +- .../RenderLayers/ShapeContainerLayer.swift | 2 +- .../DotLottie/Zip/Data+Serialization.swift | 4 +- .../Model/DotLottie/Zip/ZipArchive.swift | 44 +++++++-------- .../Zip/ZipEntry+Serialization.swift | 56 +++++++++---------- .../Model/DotLottie/Zip/ZipEntry+ZIP64.swift | 14 ++--- Sources/Private/Model/Layers/LayerModel.swift | 2 +- .../Private/Model/Layers/TextLayerModel.swift | 2 +- .../Model/ShapeItems/GradientStroke.swift | 2 +- Sources/Private/Model/ShapeItems/Stroke.swift | 2 +- Sources/Private/Model/Text/Font.swift | 2 +- .../Utility/Debugging/LayerDebugging.swift | 2 +- .../Public/Animation/LottieAnimation.swift | 4 +- .../Animation/LottieAnimationHelpers.swift | 4 +- Sources/Public/DotLottie/DotLottieFile.swift | 4 +- .../DotLottie/DotLottieFileHelpers.swift | 16 +++--- Tests/SnapshotTests.swift | 6 +- 29 files changed, 110 insertions(+), 110 deletions(-) diff --git a/Rakefile b/Rakefile index 2e31a91f63..fcfa95af70 100644 --- a/Rakefile +++ b/Rakefile @@ -136,7 +136,7 @@ def formatTool(command) url: "https://github.com/airbnb/swift", // Since we don't have a Package.resolved for this, we need to reference a specific commit // so changes to the style guide don't cause this repo's checks to start failing. - .revision("cec29280c35dd6eccba415fa3bfc24c819eae887"))) + .revision("7884f265499752cc5eccaa9eba08b4a2f8b73357"))) #endif EOC diff --git a/Sources/Private/CoreAnimation/Animations/CALayer+addAnimation.swift b/Sources/Private/CoreAnimation/Animations/CALayer+addAnimation.swift index 1a017ab3b7..555e2c2a3c 100644 --- a/Sources/Private/CoreAnimation/Animations/CALayer+addAnimation.swift +++ b/Sources/Private/CoreAnimation/Animations/CALayer+addAnimation.swift @@ -44,8 +44,7 @@ extension CALayer { keyframes: ContiguousArray>, value keyframeValueMapping: (KeyframeValue) throws -> ValueRepresentation, context: LayerAnimationContext) - throws - -> CAAnimation? + throws -> CAAnimation? { guard !keyframes.isEmpty else { return nil } @@ -87,8 +86,7 @@ extension CALayer { private func customizedAnimation( for property: LayerProperty, context: LayerAnimationContext) - throws - -> CAPropertyAnimation? + throws -> CAPropertyAnimation? { guard let customizableProperty = property.customizableProperty, @@ -162,8 +160,7 @@ extension CALayer { animationSegments: [[Keyframe]], value keyframeValueMapping: (KeyframeValue) throws -> ValueRepresentation, context: LayerAnimationContext) - throws - -> CAAnimationGroup + throws -> CAAnimationGroup { // Build the `CAKeyframeAnimation` for each segment of keyframes // with the same `CAAnimationCalculationMode`. diff --git a/Sources/Private/CoreAnimation/Animations/ShapeAnimation.swift b/Sources/Private/CoreAnimation/Animations/ShapeAnimation.swift index 76452f37ae..dc51ad8a52 100644 --- a/Sources/Private/CoreAnimation/Animations/ShapeAnimation.swift +++ b/Sources/Private/CoreAnimation/Animations/ShapeAnimation.swift @@ -87,7 +87,8 @@ extension Trim { /// The `strokeStart` and `strokeEnd` keyframes to apply to a `CAShapeLayer`, /// plus a `pathMultiplier` that should be applied to the layer's `path` so that /// trim values larger than 100% can be displayed properly. - fileprivate func caShapeLayerKeyframes(context: LayerAnimationContext) throws + fileprivate func caShapeLayerKeyframes(context: LayerAnimationContext) + throws -> (strokeStart: KeyframeGroup, strokeEnd: KeyframeGroup, pathMultiplier: PathMultiplier) { let strokeStart: KeyframeGroup @@ -186,7 +187,8 @@ extension Trim { private func adjustKeyframesForTrimOffsets( strokeKeyframes: ContiguousArray>, offsetKeyframes: ContiguousArray>, - context _: LayerAnimationContext) throws -> ContiguousArray> + context _: LayerAnimationContext) + throws -> ContiguousArray> { guard !strokeKeyframes.isEmpty, diff --git a/Sources/Private/CoreAnimation/Layers/CALayer+setupLayerHierarchy.swift b/Sources/Private/CoreAnimation/Layers/CALayer+setupLayerHierarchy.swift index f33466b111..07142e6a50 100644 --- a/Sources/Private/CoreAnimation/Layers/CALayer+setupLayerHierarchy.swift +++ b/Sources/Private/CoreAnimation/Layers/CALayer+setupLayerHierarchy.swift @@ -106,8 +106,8 @@ extension CALayer { fileprivate func maskLayer( for matteLayerModel: LayerModel, type: MatteType, - context: LayerContext) throws - -> CALayer? + context: LayerContext) + throws -> CALayer? { switch type { case .add: diff --git a/Sources/Private/CoreAnimation/Layers/PreCompLayer.swift b/Sources/Private/CoreAnimation/Layers/PreCompLayer.swift index be9950d4ef..90a506a8b9 100644 --- a/Sources/Private/CoreAnimation/Layers/PreCompLayer.swift +++ b/Sources/Private/CoreAnimation/Layers/PreCompLayer.swift @@ -110,8 +110,7 @@ extension KeyframeInterpolator where ValueType == AnimationFrameTime { static func timeRemapping( keyframes timeRemappingKeyframes: KeyframeGroup, context: LayerContext) - throws - -> KeyframeInterpolator + throws -> KeyframeInterpolator { try context.logCompatibilityIssue(""" The Core Animation rendering engine partially supports time remapping keyframes, diff --git a/Sources/Private/CoreAnimation/Layers/ShapeLayer.swift b/Sources/Private/CoreAnimation/Layers/ShapeLayer.swift index 0dafb407e2..c0bf73785d 100644 --- a/Sources/Private/CoreAnimation/Layers/ShapeLayer.swift +++ b/Sources/Private/CoreAnimation/Layers/ShapeLayer.swift @@ -194,7 +194,8 @@ extension CALayer { from items: [ShapeItem], parentGroup: Group?, parentGroupPath: [String], - context: LayerContext) throws + context: LayerContext) + throws { let groupLayers = try makeGroupLayers( from: items, @@ -214,8 +215,8 @@ extension CALayer { from items: [ShapeItem], parentGroup: Group?, parentGroupPath: [String], - context: LayerContext) throws - -> [GroupLayer] + context: LayerContext) + throws -> [GroupLayer] { var (groupItems, otherItems) = items .filter { !$0.hidden } diff --git a/Sources/Private/CoreAnimation/ValueProviderStore.swift b/Sources/Private/CoreAnimation/ValueProviderStore.swift index b7d01c7728..e1853065d4 100644 --- a/Sources/Private/CoreAnimation/ValueProviderStore.swift +++ b/Sources/Private/CoreAnimation/ValueProviderStore.swift @@ -40,8 +40,7 @@ final class ValueProviderStore { of customizableProperty: CustomizableProperty, for keypath: AnimationKeypath, context: LayerAnimationContext) - throws - -> KeyframeGroup? + throws -> KeyframeGroup? { if context.logHierarchyKeypaths { context.logger.info(keypath.fullPath) diff --git a/Sources/Private/MainThread/LayerContainers/CompLayers/MaskContainerLayer.swift b/Sources/Private/MainThread/LayerContainers/CompLayers/MaskContainerLayer.swift index d286d30cec..bdc4f06329 100644 --- a/Sources/Private/MainThread/LayerContainers/CompLayers/MaskContainerLayer.swift +++ b/Sources/Private/MainThread/LayerContainers/CompLayers/MaskContainerLayer.swift @@ -73,7 +73,7 @@ final class MaskContainerLayer: CALayer { // MARK: Internal func updateWithFrame(frame: CGFloat, forceUpdates: Bool) { - maskLayers.forEach({ $0.updateWithFrame(frame: frame, forceUpdates: forceUpdates) }) + maskLayers.forEach { $0.updateWithFrame(frame: frame, forceUpdates: forceUpdates) } } // MARK: Fileprivate diff --git a/Sources/Private/MainThread/LayerContainers/CompLayers/PreCompositionLayer.swift b/Sources/Private/MainThread/LayerContainers/CompLayers/PreCompositionLayer.swift index e1fb76d910..1af57e4842 100644 --- a/Sources/Private/MainThread/LayerContainers/CompLayers/PreCompositionLayer.swift +++ b/Sources/Private/MainThread/LayerContainers/CompLayers/PreCompositionLayer.swift @@ -107,12 +107,12 @@ final class PreCompositionLayer: CompositionLayer { } else { localFrame = (frame - startFrame) / timeStretch } - animationLayers.forEach({ $0.displayWithFrame(frame: localFrame, forceUpdates: forceUpdates) }) + animationLayers.forEach { $0.displayWithFrame(frame: localFrame, forceUpdates: forceUpdates) } } override func updateRenderScale() { super.updateRenderScale() - animationLayers.forEach({ $0.renderScale = renderScale }) + animationLayers.forEach { $0.renderScale = renderScale } } // MARK: Fileprivate diff --git a/Sources/Private/MainThread/LayerContainers/MainThreadAnimationLayer.swift b/Sources/Private/MainThread/LayerContainers/MainThreadAnimationLayer.swift index f597d51928..1636228672 100644 --- a/Sources/Private/MainThread/LayerContainers/MainThreadAnimationLayer.swift +++ b/Sources/Private/MainThread/LayerContainers/MainThreadAnimationLayer.swift @@ -170,7 +170,7 @@ final class MainThreadAnimationLayer: CALayer, RootAnimationLayer { var renderScale: CGFloat = 1 { didSet { - animationLayers.forEach({ $0.renderScale = renderScale }) + animationLayers.forEach { $0.renderScale = renderScale } } } @@ -194,12 +194,12 @@ final class MainThreadAnimationLayer: CALayer, RootAnimationLayer { /// Forces the view to update its drawing. func forceDisplayUpdate() { - animationLayers.forEach({ $0.displayWithFrame(frame: currentFrame, forceUpdates: true) }) + animationLayers.forEach { $0.displayWithFrame(frame: currentFrame, forceUpdates: true) } } func logHierarchyKeypaths() { logger.info("Lottie: Logging Animation Keypaths") - animationLayers.forEach({ $0.logKeypaths(for: nil, logger: self.logger) }) + animationLayers.forEach { $0.logKeypaths(for: nil, logger: self.logger) } } func setValueProvider(_ valueProvider: AnyValueProvider, keypath: AnimationKeypath) { diff --git a/Sources/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/GroupInterpolator.swift b/Sources/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/GroupInterpolator.swift index 8be2dc2363..53c95b834f 100644 --- a/Sources/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/GroupInterpolator.swift +++ b/Sources/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/GroupInterpolator.swift @@ -15,7 +15,7 @@ final class GroupInterpolator: ValueProvider where ValueType: Interpo /// Initialize with an array of array of keyframes. init(keyframeGroups: ContiguousArray>>) { - keyframeInterpolators = ContiguousArray(keyframeGroups.map({ KeyframeInterpolator(keyframes: $0) })) + keyframeInterpolators = ContiguousArray(keyframeGroups.map { KeyframeInterpolator(keyframes: $0) }) } // MARK: Internal @@ -28,7 +28,7 @@ final class GroupInterpolator: ValueProvider where ValueType: Interpo var storage: ValueProviderStorage<[ValueType]> { .closure { frame in - self.keyframeInterpolators.map({ $0.value(frame: frame) as! ValueType }) + self.keyframeInterpolators.map { $0.value(frame: frame) as! ValueType } } } diff --git a/Sources/Private/MainThread/NodeRenderSystem/Nodes/ModifierNodes/TrimPathNode.swift b/Sources/Private/MainThread/NodeRenderSystem/Nodes/ModifierNodes/TrimPathNode.swift index 38be0caab1..2d0ec0906f 100644 --- a/Sources/Private/MainThread/NodeRenderSystem/Nodes/ModifierNodes/TrimPathNode.swift +++ b/Sources/Private/MainThread/NodeRenderSystem/Nodes/ModifierNodes/TrimPathNode.swift @@ -133,7 +133,7 @@ final class TrimPathNode: AnimatorNode { /// First get the total length of all paths. var totalLength: CGFloat = 0 - upstreamPaths.forEach({ totalLength = totalLength + $0.totalLength }) + upstreamPaths.forEach { totalLength = totalLength + $0.totalLength } /// Now determine the start and end cut lengths let startLength = startPosition * totalLength diff --git a/Sources/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/StrokeRenderer.swift b/Sources/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/StrokeRenderer.swift index a78db35f8c..39c0668136 100644 --- a/Sources/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/StrokeRenderer.swift +++ b/Sources/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/StrokeRenderer.swift @@ -160,7 +160,7 @@ final class StrokeRenderer: PassThroughOutputNode, Renderable { layer.lineDashPhase = dashPhase ?? 0 layer.fillColor = nil if let dashPattern = dashLengths { - layer.lineDashPattern = dashPattern.map({ NSNumber(value: Double($0)) }) + layer.lineDashPattern = dashPattern.map { NSNumber(value: Double($0)) } } } } diff --git a/Sources/Private/MainThread/NodeRenderSystem/RenderLayers/ShapeContainerLayer.swift b/Sources/Private/MainThread/NodeRenderSystem/RenderLayers/ShapeContainerLayer.swift index 7aaaa4453a..25c2314fff 100644 --- a/Sources/Private/MainThread/NodeRenderSystem/RenderLayers/ShapeContainerLayer.swift +++ b/Sources/Private/MainThread/NodeRenderSystem/RenderLayers/ShapeContainerLayer.swift @@ -69,7 +69,7 @@ class ShapeContainerLayer: CALayer { func updateRenderScale() { contentsScale = renderScale - renderLayers.forEach({ $0.renderScale = renderScale }) + renderLayers.forEach { $0.renderScale = renderScale } } } diff --git a/Sources/Private/Model/DotLottie/Zip/Data+Serialization.swift b/Sources/Private/Model/DotLottie/Zip/Data+Serialization.swift index 9093fdc310..43a493ef4f 100644 --- a/Sources/Private/Model/DotLottie/Zip/Data+Serialization.swift +++ b/Sources/Private/Model/DotLottie/Zip/Data+Serialization.swift @@ -53,9 +53,9 @@ extension Data { throw DataError.unreadableFile } #if swift(>=4.1) - return Data(bytesNoCopy: bytes, count: bytesRead, deallocator: .custom({ buf, _ in buf.deallocate() })) + return Data(bytesNoCopy: bytes, count: bytesRead, deallocator: .custom { buf, _ in buf.deallocate() }) #else - let deallocator = Deallocator.custom({ buf, _ in buf.deallocate(bytes: size, alignedTo: 1) }) + let deallocator = Deallocator.custom { buf, _ in buf.deallocate(bytes: size, alignedTo: 1) } return Data(bytesNoCopy: bytes, count: bytesRead, deallocator: deallocator) #endif } diff --git a/Sources/Private/Model/DotLottie/Zip/ZipArchive.swift b/Sources/Private/Model/DotLottie/Zip/ZipArchive.swift index 11272fa63a..f1923059d5 100644 --- a/Sources/Private/Model/DotLottie/Zip/ZipArchive.swift +++ b/Sources/Private/Model/DotLottie/Zip/ZipArchive.swift @@ -383,16 +383,16 @@ extension ZipArchive.ZIP64EndOfCentralDirectoryRecord { var sizeOfCD = sizeOfCentralDirectory var offsetToStartOfCD = offsetToStartOfCentralDirectory var data = Data() - withUnsafePointer(to: &zip64EOCDRecordSignature, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &sizeOfZIP64EOCDRecord, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &versionMadeBy, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &versionNeededToExtract, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &numberOfDisk, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &numberOfDiskStart, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &totalNumberOfEntriesOnDisk, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &totalNumberOfEntriesInCD, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &sizeOfCD, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &offsetToStartOfCD, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) + withUnsafePointer(to: &zip64EOCDRecordSignature) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &sizeOfZIP64EOCDRecord) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &versionMadeBy) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &versionNeededToExtract) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &numberOfDisk) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &numberOfDiskStart) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &totalNumberOfEntriesOnDisk) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &totalNumberOfEntriesInCD) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &sizeOfCD) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &offsetToStartOfCD) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } data.append(zip64ExtensibleDataSector) return data } @@ -419,10 +419,10 @@ extension ZipArchive.ZIP64EndOfCentralDirectoryLocator { var offsetOfZIP64EOCDRecord = relativeOffsetOfZIP64EOCDRecord var totalNumberOfDisk = totalNumberOfDisk var data = Data() - withUnsafePointer(to: &zip64EOCDLocatorSignature, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &numberOfDiskWithZIP64EOCD, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &offsetOfZIP64EOCDRecord, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &totalNumberOfDisk, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) + withUnsafePointer(to: &zip64EOCDLocatorSignature) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &numberOfDiskWithZIP64EOCD) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &offsetOfZIP64EOCDRecord) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &totalNumberOfDisk) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } return data } @@ -459,14 +459,14 @@ extension ZipArchive.EndOfCentralDirectoryRecord { var offsetToStartOfCD = offsetToStartOfCentralDirectory var zipFileCommentLength = zipFileCommentLength var data = Data() - withUnsafePointer(to: &endOfCDSignature, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &numberOfDisk, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &numberOfDiskStart, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &totalNumberOfEntriesOnDisk, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &totalNumberOfEntriesInCD, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &sizeOfCentralDirectory, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &offsetToStartOfCD, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &zipFileCommentLength, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) + withUnsafePointer(to: &endOfCDSignature) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &numberOfDisk) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &numberOfDiskStart) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &totalNumberOfEntriesOnDisk) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &totalNumberOfEntriesInCD) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &sizeOfCentralDirectory) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &offsetToStartOfCD) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &zipFileCommentLength) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } data.append(zipFileCommentData) return data } diff --git a/Sources/Private/Model/DotLottie/Zip/ZipEntry+Serialization.swift b/Sources/Private/Model/DotLottie/Zip/ZipEntry+Serialization.swift index a50c34edf1..ad387309b4 100644 --- a/Sources/Private/Model/DotLottie/Zip/ZipEntry+Serialization.swift +++ b/Sources/Private/Model/DotLottie/Zip/ZipEntry+Serialization.swift @@ -60,17 +60,17 @@ extension ZipEntry.LocalFileHeader { var fileNameLength = fileNameLength var extraFieldLength = extraFieldLength var data = Data() - withUnsafePointer(to: &localFileHeaderSignature, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &versionNeededToExtract, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &generalPurposeBitFlag, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &compressionMethod, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &lastModFileTime, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &lastModFileDate, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &crc32, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &compressedSize, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &uncompressedSize, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &fileNameLength, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &extraFieldLength, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) + withUnsafePointer(to: &localFileHeaderSignature) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &versionNeededToExtract) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &generalPurposeBitFlag) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &compressionMethod) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &lastModFileTime) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &lastModFileDate) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &crc32) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &compressedSize) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &uncompressedSize) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &fileNameLength) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &extraFieldLength) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } data.append(fileNameData) data.append(extraFieldData) return data @@ -143,23 +143,23 @@ extension ZipEntry.CentralDirectoryStructure { var externalFileAttributes = externalFileAttributes var relativeOffsetOfLocalHeader = relativeOffsetOfLocalHeader var data = Data() - withUnsafePointer(to: ¢ralDirectorySignature, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &versionMadeBy, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &versionNeededToExtract, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &generalPurposeBitFlag, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &compressionMethod, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &lastModFileTime, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &lastModFileDate, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &crc32, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &compressedSize, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &uncompressedSize, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &fileNameLength, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &extraFieldLength, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &fileCommentLength, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &diskNumberStart, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &internalFileAttributes, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &externalFileAttributes, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &relativeOffsetOfLocalHeader, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) + withUnsafePointer(to: ¢ralDirectorySignature) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &versionMadeBy) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &versionNeededToExtract) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &generalPurposeBitFlag) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &compressionMethod) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &lastModFileTime) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &lastModFileDate) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &crc32) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &compressedSize) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &uncompressedSize) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &fileNameLength) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &extraFieldLength) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &fileCommentLength) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &diskNumberStart) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &internalFileAttributes) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &externalFileAttributes) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &relativeOffsetOfLocalHeader) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } data.append(fileNameData) data.append(extraFieldData) data.append(fileCommentData) diff --git a/Sources/Private/Model/DotLottie/Zip/ZipEntry+ZIP64.swift b/Sources/Private/Model/DotLottie/Zip/ZipEntry+ZIP64.swift index 686a59434e..6be63323ec 100644 --- a/Sources/Private/Model/DotLottie/Zip/ZipEntry+ZIP64.swift +++ b/Sources/Private/Model/DotLottie/Zip/ZipEntry+ZIP64.swift @@ -111,7 +111,7 @@ extension ZipEntry.ZIP64ExtendedInformation { diskNumberStart = existingInfo.diskNumberStart let tempDataSize = [relativeOffsetOfLocalHeader, uncompressedSize, compressedSize] .filter { $0 != 0 } - .reduce(UInt16(0), { $0 + UInt16(MemoryLayout.size(ofValue: $1)) }) + .reduce(UInt16(0)) { $0 + UInt16(MemoryLayout.size(ofValue: $1)) } dataSize = tempDataSize + (diskNumberStart > 0 ? UInt16(MemoryLayout.size(ofValue: diskNumberStart)) : 0) if dataSize == 0 { return nil } } @@ -142,17 +142,17 @@ extension ZipEntry.ZIP64ExtendedInformation { var relativeOffsetOfLFH = relativeOffsetOfLocalHeader var diskNumberStart = diskNumberStart var data = Data() - withUnsafePointer(to: &headerID, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &dataSize, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) + withUnsafePointer(to: &headerID) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &dataSize) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } if uncompressedSize != 0 || compressedSize != 0 { - withUnsafePointer(to: &uncompressedSize, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) - withUnsafePointer(to: &compressedSize, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) + withUnsafePointer(to: &uncompressedSize) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } + withUnsafePointer(to: &compressedSize) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } } if relativeOffsetOfLocalHeader != 0 { - withUnsafePointer(to: &relativeOffsetOfLFH, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) + withUnsafePointer(to: &relativeOffsetOfLFH) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } } if diskNumberStart != 0 { - withUnsafePointer(to: &diskNumberStart, { data.append(UnsafeBufferPointer(start: $0, count: 1)) }) + withUnsafePointer(to: &diskNumberStart) { data.append(UnsafeBufferPointer(start: $0, count: 1)) } } return data } diff --git a/Sources/Private/Model/Layers/LayerModel.swift b/Sources/Private/Model/Layers/LayerModel.swift index e4604205ce..5fc3807f61 100644 --- a/Sources/Private/Model/Layers/LayerModel.swift +++ b/Sources/Private/Model/Layers/LayerModel.swift @@ -127,7 +127,7 @@ class LayerModel: Codable, DictionaryInitializable { blendMode = .normal } if let maskDictionaries = dictionary[CodingKeys.masks.rawValue] as? [[String: Any]] { - masks = try maskDictionaries.map({ try Mask(dictionary: $0) }) + masks = try maskDictionaries.map { try Mask(dictionary: $0) } } else { masks = nil } diff --git a/Sources/Private/Model/Layers/TextLayerModel.swift b/Sources/Private/Model/Layers/TextLayerModel.swift index f4db922a5b..0dc6f0e09f 100644 --- a/Sources/Private/Model/Layers/TextLayerModel.swift +++ b/Sources/Private/Model/Layers/TextLayerModel.swift @@ -25,7 +25,7 @@ final class TextLayerModel: LayerModel { let textDictionary: [String: Any] = try containerDictionary.value(for: TextCodingKeys.text) text = try KeyframeGroup(dictionary: textDictionary) let animatorDictionaries: [[String: Any]] = try containerDictionary.value(for: TextCodingKeys.animators) - animators = try animatorDictionaries.map({ try TextAnimator(dictionary: $0) }) + animators = try animatorDictionaries.map { try TextAnimator(dictionary: $0) } try super.init(dictionary: dictionary) } diff --git a/Sources/Private/Model/ShapeItems/GradientStroke.swift b/Sources/Private/Model/ShapeItems/GradientStroke.swift index d82f5b818a..e0e22f139f 100644 --- a/Sources/Private/Model/ShapeItems/GradientStroke.swift +++ b/Sources/Private/Model/ShapeItems/GradientStroke.swift @@ -97,7 +97,7 @@ final class GradientStroke: ShapeItem { colors = try KeyframeGroup<[Double]>(dictionary: nestedColorsDictionary) numberOfColors = try colorsDictionary.value(for: GradientDataKeys.numberOfColors) let dashPatternDictionaries = dictionary[CodingKeys.dashPattern.rawValue] as? [[String: Any]] - dashPattern = try? dashPatternDictionaries?.map({ try DashElement(dictionary: $0) }) + dashPattern = try? dashPatternDictionaries?.map { try DashElement(dictionary: $0) } try super.init(dictionary: dictionary) } diff --git a/Sources/Private/Model/ShapeItems/Stroke.swift b/Sources/Private/Model/ShapeItems/Stroke.swift index a699ba5436..5b4f860598 100644 --- a/Sources/Private/Model/ShapeItems/Stroke.swift +++ b/Sources/Private/Model/ShapeItems/Stroke.swift @@ -48,7 +48,7 @@ final class Stroke: ShapeItem { } miterLimit = (try? dictionary.value(for: CodingKeys.miterLimit)) ?? 4 let dashPatternDictionaries = dictionary[CodingKeys.dashPattern.rawValue] as? [[String: Any]] - dashPattern = try? dashPatternDictionaries?.map({ try DashElement(dictionary: $0) }) + dashPattern = try? dashPatternDictionaries?.map { try DashElement(dictionary: $0) } try super.init(dictionary: dictionary) } diff --git a/Sources/Private/Model/Text/Font.swift b/Sources/Private/Model/Text/Font.swift index d78ee0dcdd..c1c9869252 100644 --- a/Sources/Private/Model/Text/Font.swift +++ b/Sources/Private/Model/Text/Font.swift @@ -47,7 +47,7 @@ final class FontList: Codable, DictionaryInitializable { init(dictionary: [String: Any]) throws { let fontDictionaries: [[String: Any]] = try dictionary.value(for: CodingKeys.fonts) - fonts = try fontDictionaries.map({ try Font(dictionary: $0) }) + fonts = try fontDictionaries.map { try Font(dictionary: $0) } } // MARK: Internal diff --git a/Sources/Private/Utility/Debugging/LayerDebugging.swift b/Sources/Private/Utility/Debugging/LayerDebugging.swift index 15e736e4f7..9482f65a55 100644 --- a/Sources/Private/Utility/Debugging/LayerDebugging.swift +++ b/Sources/Private/Utility/Debugging/LayerDebugging.swift @@ -90,7 +90,7 @@ extension CALayer { } if let sublayers = sublayers { - sublayers.forEach({ $0.setDebuggingState(visible: visible) }) + sublayers.forEach { $0.setDebuggingState(visible: visible) } } if visible { diff --git a/Sources/Public/Animation/LottieAnimation.swift b/Sources/Public/Animation/LottieAnimation.swift index 5e619ba4eb..98cdef1249 100644 --- a/Sources/Public/Animation/LottieAnimation.swift +++ b/Sources/Public/Animation/LottieAnimation.swift @@ -68,7 +68,7 @@ public final class LottieAnimation: Codable, DictionaryInitializable { let layerDictionaries: [[String: Any]] = try dictionary.value(for: CodingKeys.layers) layers = try [LayerModel].fromDictionaries(layerDictionaries) if let glyphDictionaries = dictionary[CodingKeys.glyphs.rawValue] as? [[String: Any]] { - glyphs = try glyphDictionaries.map({ try Glyph(dictionary: $0) }) + glyphs = try glyphDictionaries.map { try Glyph(dictionary: $0) } } else { glyphs = nil } @@ -83,7 +83,7 @@ public final class LottieAnimation: Codable, DictionaryInitializable { assetLibrary = nil } if let markerDictionaries = dictionary[CodingKeys.markers.rawValue] as? [[String: Any]] { - let markers = try markerDictionaries.map({ try Marker(dictionary: $0) }) + let markers = try markerDictionaries.map { try Marker(dictionary: $0) } var markerMap: [String: Marker] = [:] for marker in markers { markerMap[marker.name] = marker diff --git a/Sources/Public/Animation/LottieAnimationHelpers.swift b/Sources/Public/Animation/LottieAnimationHelpers.swift index 0be2ef699b..92d0371eaf 100644 --- a/Sources/Public/Animation/LottieAnimationHelpers.swift +++ b/Sources/Public/Animation/LottieAnimationHelpers.swift @@ -149,8 +149,8 @@ extension LottieAnimation { /// public static func from( data: Data, - strategy: DecodingStrategy = LottieConfiguration.shared.decodingStrategy) throws - -> LottieAnimation + strategy: DecodingStrategy = LottieConfiguration.shared.decodingStrategy) + throws -> LottieAnimation { switch strategy { case .legacyCodable: diff --git a/Sources/Public/DotLottie/DotLottieFile.swift b/Sources/Public/DotLottie/DotLottieFile.swift index fb4039829b..85e3c6f545 100644 --- a/Sources/Public/DotLottie/DotLottieFile.swift +++ b/Sources/Public/DotLottie/DotLottieFile.swift @@ -86,11 +86,11 @@ public final class DotLottieFile { private let fileUrl: URL private var dotLottieAnimations: [DotLottieAnimation] { - manifest?.animations.map({ + manifest?.animations.map { var animation = $0 animation.animationUrl = animationsUrl.appendingPathComponent("\($0.id).json") return animation - }) ?? [] + } ?? [] } /// Decompresses .lottie file from `URL` and saves to local temp folder diff --git a/Sources/Public/DotLottie/DotLottieFileHelpers.swift b/Sources/Public/DotLottie/DotLottieFileHelpers.swift index 845ab2341f..fa743c18d9 100644 --- a/Sources/Public/DotLottie/DotLottieFileHelpers.swift +++ b/Sources/Public/DotLottie/DotLottieFileHelpers.swift @@ -20,8 +20,8 @@ extension DotLottieFile { _ name: String, bundle: Bundle = Bundle.main, subdirectory: String? = nil, - dotLottieCache: DotLottieCacheProvider? = DotLottieCache.sharedCache) async throws - -> DotLottieFile + dotLottieCache: DotLottieCacheProvider? = DotLottieCache.sharedCache) + async throws -> DotLottieFile { try await withCheckedThrowingContinuation { continuation in DotLottieFile.named(name, bundle: bundle, subdirectory: subdirectory, dotLottieCache: dotLottieCache) { result in @@ -89,8 +89,8 @@ extension DotLottieFile { @available(iOS 13.0, macOS 10.15, tvOS 13.0, *) public static func loadedFrom( filepath: String, - dotLottieCache: DotLottieCacheProvider? = DotLottieCache.sharedCache) async throws - -> DotLottieFile + dotLottieCache: DotLottieCacheProvider? = DotLottieCache.sharedCache) + async throws -> DotLottieFile { try await withCheckedThrowingContinuation { continuation in DotLottieFile.loadedFrom(filepath: filepath, dotLottieCache: dotLottieCache) { result in @@ -146,8 +146,8 @@ extension DotLottieFile { public static func asset( named name: String, bundle: Bundle = Bundle.main, - dotLottieCache: DotLottieCacheProvider? = DotLottieCache.sharedCache) async throws - -> DotLottieFile + dotLottieCache: DotLottieCacheProvider? = DotLottieCache.sharedCache) + async throws -> DotLottieFile { try await withCheckedThrowingContinuation { continuation in DotLottieFile.asset(named: name, bundle: bundle, dotLottieCache: dotLottieCache) { result in @@ -215,8 +215,8 @@ extension DotLottieFile { public static func loadedFrom( url: URL, session: URLSession = .shared, - dotLottieCache: DotLottieCacheProvider? = DotLottieCache.sharedCache) async throws - -> DotLottieFile + dotLottieCache: DotLottieCacheProvider? = DotLottieCache.sharedCache) + async throws -> DotLottieFile { try await withCheckedThrowingContinuation { continuation in DotLottieFile.loadedFrom(url: url, session: session, dotLottieCache: dotLottieCache) { result in diff --git a/Tests/SnapshotTests.swift b/Tests/SnapshotTests.swift index 33f89e6f76..dfedd1aa0a 100644 --- a/Tests/SnapshotTests.swift +++ b/Tests/SnapshotTests.swift @@ -101,7 +101,8 @@ class SnapshotTests: XCTestCase { /// Captures snapshots of `sampleAnimationURLs` and compares them to the snapshot images stored on disk private func compareSampleSnapshots( configuration: LottieConfiguration, - testName: String = #function) async throws + testName: String = #function) + async throws { #if os(iOS) guard UIScreen.main.scale == 2 else { @@ -244,7 +245,8 @@ extension SnapshotConfiguration { for sampleAnimationName: String, configuration: LottieConfiguration, logger: LottieLogger = LottieLogger.shared) - async -> LottieAnimationView? { + async -> LottieAnimationView? + { let snapshotConfiguration = SnapshotConfiguration.forSample(named: sampleAnimationName) guard snapshotConfiguration.shouldSnapshot(using: configuration) else {