Skip to content

Commit

Permalink
Update to latest version of Airbnb style formatter plugin (#1797)
Browse files Browse the repository at this point in the history
  • Loading branch information
calda authored Nov 3, 2022
1 parent 0a9d2fc commit d03f49a
Show file tree
Hide file tree
Showing 29 changed files with 110 additions and 110 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ extension CALayer {
keyframes: ContiguousArray<Keyframe<KeyframeValue>>,
value keyframeValueMapping: (KeyframeValue) throws -> ValueRepresentation,
context: LayerAnimationContext)
throws
-> CAAnimation?
throws -> CAAnimation?
{
guard !keyframes.isEmpty else { return nil }

Expand Down Expand Up @@ -87,8 +86,7 @@ extension CALayer {
private func customizedAnimation<ValueRepresentation>(
for property: LayerProperty<ValueRepresentation>,
context: LayerAnimationContext)
throws
-> CAPropertyAnimation?
throws -> CAPropertyAnimation?
{
guard
let customizableProperty = property.customizableProperty,
Expand Down Expand Up @@ -162,8 +160,7 @@ extension CALayer {
animationSegments: [[Keyframe<KeyframeValue>]],
value keyframeValueMapping: (KeyframeValue) throws -> ValueRepresentation,
context: LayerAnimationContext)
throws
-> CAAnimationGroup
throws -> CAAnimationGroup
{
// Build the `CAKeyframeAnimation` for each segment of keyframes
// with the same `CAAnimationCalculationMode`.
Expand Down
6 changes: 4 additions & 2 deletions Sources/Private/CoreAnimation/Animations/ShapeAnimation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<LottieVector1D>, strokeEnd: KeyframeGroup<LottieVector1D>, pathMultiplier: PathMultiplier)
{
let strokeStart: KeyframeGroup<LottieVector1D>
Expand Down Expand Up @@ -186,7 +187,8 @@ extension Trim {
private func adjustKeyframesForTrimOffsets(
strokeKeyframes: ContiguousArray<Keyframe<LottieVector1D>>,
offsetKeyframes: ContiguousArray<Keyframe<LottieVector1D>>,
context _: LayerAnimationContext) throws -> ContiguousArray<Keyframe<LottieVector1D>>
context _: LayerAnimationContext)
throws -> ContiguousArray<Keyframe<LottieVector1D>>
{
guard
!strokeKeyframes.isEmpty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions Sources/Private/CoreAnimation/Layers/PreCompLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ extension KeyframeInterpolator where ValueType == AnimationFrameTime {
static func timeRemapping(
keyframes timeRemappingKeyframes: KeyframeGroup<LottieVector1D>,
context: LayerContext)
throws
-> KeyframeInterpolator<AnimationFrameTime>
throws -> KeyframeInterpolator<AnimationFrameTime>
{
try context.logCompatibilityIssue("""
The Core Animation rendering engine partially supports time remapping keyframes,
Expand Down
7 changes: 4 additions & 3 deletions Sources/Private/CoreAnimation/Layers/ShapeLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 }
Expand Down
3 changes: 1 addition & 2 deletions Sources/Private/CoreAnimation/ValueProviderStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ final class ValueProviderStore {
of customizableProperty: CustomizableProperty<Value>,
for keypath: AnimationKeypath,
context: LayerAnimationContext)
throws
-> KeyframeGroup<Value>?
throws -> KeyframeGroup<Value>?
{
if context.logHierarchyKeypaths {
context.logger.info(keypath.fullPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ final class MainThreadAnimationLayer: CALayer, RootAnimationLayer {

var renderScale: CGFloat = 1 {
didSet {
animationLayers.forEach({ $0.renderScale = renderScale })
animationLayers.forEach { $0.renderScale = renderScale }
}
}

Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class GroupInterpolator<ValueType>: ValueProvider where ValueType: Interpo

/// Initialize with an array of array of keyframes.
init(keyframeGroups: ContiguousArray<ContiguousArray<Keyframe<ValueType>>>) {
keyframeInterpolators = ContiguousArray(keyframeGroups.map({ KeyframeInterpolator(keyframes: $0) }))
keyframeInterpolators = ContiguousArray(keyframeGroups.map { KeyframeInterpolator(keyframes: $0) })
}

// MARK: Internal
Expand All @@ -28,7 +28,7 @@ final class GroupInterpolator<ValueType>: 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 }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class ShapeContainerLayer: CALayer {

func updateRenderScale() {
contentsScale = renderScale
renderLayers.forEach({ $0.renderScale = renderScale })
renderLayers.forEach { $0.renderScale = renderScale }
}

}
4 changes: 2 additions & 2 deletions Sources/Private/Model/DotLottie/Zip/Data+Serialization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
44 changes: 22 additions & 22 deletions Sources/Private/Model/DotLottie/Zip/ZipArchive.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}

Expand Down Expand Up @@ -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
}
Expand Down
Loading

0 comments on commit d03f49a

Please sign in to comment.