Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run swiftformat #1137

Merged
merged 2 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/SwifterSwift/AppKit/NSColorExtensions.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// NSColorExtensions.swift - Copyright 2020 SwifterSwift
// NSColorExtensions.swift - Copyright 2023 SwifterSwift

#if canImport(AppKit) && !targetEnvironment(macCatalyst)
import AppKit
Expand Down
5 changes: 3 additions & 2 deletions Sources/SwifterSwift/AppKit/NSImageExtensions.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// NSImageExtensions.swift - Copyright 2020 SwifterSwift
// NSImageExtensions.swift - Copyright 2023 SwifterSwift

#if canImport(AppKit) && !targetEnvironment(macCatalyst)
import AppKit
Expand Down Expand Up @@ -45,7 +45,8 @@ public extension NSImage {
/// - Parameters:
/// - url: Desired file URL.
/// - type: Type of image (default is .jpeg).
/// - compressionFactor: used only for JPEG files. The value is a float between 0.0 and 1.0, with 1.0 resulting in no compression and 0.0 resulting in the maximum compression possible.
/// - compressionFactor: used only for JPEG files. The value is a float between 0.0 and 1.0, with 1.0 resulting in
/// no compression and 0.0 resulting in the maximum compression possible.
func write(to url: URL, fileType type: NSBitmapImageRep.FileType = .jpeg, compressionFactor: NSNumber = 1.0) {
// https://stackoverflow.com/a/45042611/3882644

Expand Down
2 changes: 1 addition & 1 deletion Sources/SwifterSwift/AppKit/NSViewExtensions.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// NSViewExtensions.swift - Copyright 2020 SwifterSwift
// NSViewExtensions.swift - Copyright 2023 SwifterSwift

#if canImport(AppKit) && !targetEnvironment(macCatalyst)
import AppKit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// CAGradientLayerExtensions.swift - Copyright 2020 SwifterSwift
// CAGradientLayerExtensions.swift - Copyright 2023 SwifterSwift

#if !os(watchOS) && !os(Linux) && canImport(QuartzCore)
import QuartzCore
Expand All @@ -14,9 +14,11 @@ public extension CAGradientLayer {
/// assumed to spread uniformly across the [0,1] range. When rendered,
/// the colors are mapped to the output colorspace before being
/// interpolated (default is nil).
/// - startPoint: start point corresponds to the first gradient stop (I.e. [0,0] is the bottom-corner of the layer, [1,1] is the top-right corner).
/// - startPoint: start point corresponds to the first gradient stop (I.e. [0,0] is the bottom-corner of the
/// layer, [1,1] is the top-right corner).
/// - endPoint: end point corresponds to the last gradient stop
/// - type: The kind of gradient that will be drawn. Currently, the only allowed values are `axial' (the default value), `radial', and `conic'.
/// - type: The kind of gradient that will be drawn. Currently, the only allowed values are `axial' (the default
/// value), `radial', and `conic'.
convenience init(colors: [SFColor],
locations: [CGFloat]? = nil,
startPoint: CGPoint = CGPoint(x: 0.5, y: 0),
Expand Down
37 changes: 19 additions & 18 deletions Sources/SwifterSwift/CoreAnimation/CATransform3DExtensions.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// CATransform3DExtensions.swift - Copyright 2020 SwifterSwift
// CATransform3DExtensions.swift - Copyright 2023 SwifterSwift

// swiftlint:disable identifier_name

Expand Down Expand Up @@ -42,27 +42,28 @@ extension CATransform3D: Codable {

/// Creates a new instance by decoding from the given decoder.
///
/// This initializer throws an error if reading from the decoder fails, or if the data read is corrupted or otherwise invalid.
/// This initializer throws an error if reading from the decoder fails, or if the data read is corrupted or
/// otherwise invalid.
/// - Parameter decoder: The decoder to read data from.
@inlinable
public init(from decoder: Decoder) throws {
var container = try decoder.unkeyedContainer()
self.init(m11: try container.decode(CGFloat.self),
m12: try container.decode(CGFloat.self),
m13: try container.decode(CGFloat.self),
m14: try container.decode(CGFloat.self),
m21: try container.decode(CGFloat.self),
m22: try container.decode(CGFloat.self),
m23: try container.decode(CGFloat.self),
m24: try container.decode(CGFloat.self),
m31: try container.decode(CGFloat.self),
m32: try container.decode(CGFloat.self),
m33: try container.decode(CGFloat.self),
m34: try container.decode(CGFloat.self),
m41: try container.decode(CGFloat.self),
m42: try container.decode(CGFloat.self),
m43: try container.decode(CGFloat.self),
m44: try container.decode(CGFloat.self))
try self.init(m11: container.decode(CGFloat.self),
m12: container.decode(CGFloat.self),
m13: container.decode(CGFloat.self),
m14: container.decode(CGFloat.self),
m21: container.decode(CGFloat.self),
m22: container.decode(CGFloat.self),
m23: container.decode(CGFloat.self),
m24: container.decode(CGFloat.self),
m31: container.decode(CGFloat.self),
m32: container.decode(CGFloat.self),
m33: container.decode(CGFloat.self),
m34: container.decode(CGFloat.self),
m41: container.decode(CGFloat.self),
m42: container.decode(CGFloat.self),
m43: container.decode(CGFloat.self),
m44: container.decode(CGFloat.self))
}

/// Encodes this value into the given encoder.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// CGAffineTransformExtensions.swift - Copyright 2020 SwifterSwift
// CGAffineTransformExtensions.swift - Copyright 2023 SwifterSwift

#if canImport(CoreGraphics)
import CoreGraphics
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwifterSwift/CoreGraphics/CGColorExtensions.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// CGColorExtensions.swift - Copyright 2020 SwifterSwift
// CGColorExtensions.swift - Copyright 2023 SwifterSwift

#if canImport(CoreGraphics)
import CoreGraphics
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwifterSwift/CoreGraphics/CGFloatExtensions.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// CGFloatExtensions.swift - Copyright 2020 SwifterSwift
// CGFloatExtensions.swift - Copyright 2023 SwifterSwift

#if canImport(CoreGraphics)
import CoreGraphics
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwifterSwift/CoreGraphics/CGPointExtensions.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// CGPointExtensions.swift - Copyright 2020 SwifterSwift
// CGPointExtensions.swift - Copyright 2023 SwifterSwift

#if canImport(CoreGraphics)
import CoreGraphics
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwifterSwift/CoreGraphics/CGRectExtensions.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// CGRectExtensions.swift - Copyright 2020 SwifterSwift
// CGRectExtensions.swift - Copyright 2023 SwifterSwift

#if canImport(CoreGraphics)
import CoreGraphics
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwifterSwift/CoreGraphics/CGSizeExtensions.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// CGSizeExtensions.swift - Copyright 2020 SwifterSwift
// CGSizeExtensions.swift - Copyright 2023 SwifterSwift

#if canImport(CoreGraphics)
import CoreGraphics
Expand Down
5 changes: 3 additions & 2 deletions Sources/SwifterSwift/CoreGraphics/CGVectorExtensions.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// CGVectorExtensions.swift - Copyright 2020 SwifterSwift
// CGVectorExtensions.swift - Copyright 2023 SwifterSwift

#if canImport(CoreGraphics)
import CoreGraphics

// MARK: - Properties

public extension CGVector {
/// SwifterSwift: The angle of rotation (in radians) of the vector. The range of the angle is -π to π; an angle of 0 points to the right.
/// SwifterSwift: The angle of rotation (in radians) of the vector. The range of the angle is -π to π; an angle of 0
/// points to the right.
///
/// https://en.wikipedia.org/wiki/Atan2
var angle: CGFloat {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// CLLocationArrayExtensions.swift - Copyright 2020 SwifterSwift
// CLLocationArrayExtensions.swift - Copyright 2023 SwifterSwift

#if canImport(CoreLocation)
import CoreLocation

// MARK: - Methods

public extension Array where Element: CLLocation {
/// SwifterSwift: Calculates the sum of distances between each location in the array based on the curvature of the earth.
/// SwifterSwift: Calculates the sum of distances between each location in the array based on the curvature of the
/// earth.
///
/// - Parameter unit: The unit of length to return the distance in.
/// - Returns: The distance in the specified unit.
Expand Down
5 changes: 3 additions & 2 deletions Sources/SwifterSwift/CoreLocation/CLLocationExtensions.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// CLLocationExtensions.swift - Copyright 2020 SwifterSwift
// CLLocationExtensions.swift - Copyright 2023 SwifterSwift

#if canImport(CoreLocation)
import CoreLocation
Expand Down Expand Up @@ -70,7 +70,8 @@ public extension CLLocation {
/// - location: End location.
/// - radius: Range limit distance.
/// - unit: The unit of length. Default value is `.meters`.
/// - Returns: `true` if the distance between the receiver and `location` is less than or equal to the given `radius`.
/// - Returns: `true` if the distance between the receiver and `location` is less than or equal to the given
/// `radius`.
@available(iOS 10.12, macOS 10.12, tvOS 10.0, watchOS 3.0, *)
func isInRange(of location: CLLocation, radius: Double, unitLength unit: UnitLength = .meters) -> Bool {
let distance = Measurement(value: radius, unit: unit).converted(to: .meters).value
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwifterSwift/CoreLocation/CLVisitExtensions.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// CLVisitExtensions.swift - Copyright 2020 SwifterSwift
// CLVisitExtensions.swift - Copyright 2023 SwifterSwift

#if canImport(CoreLocation) && (os(iOS) || targetEnvironment(macCatalyst))
import CoreLocation
Expand Down
5 changes: 2 additions & 3 deletions Sources/SwifterSwift/CryptoKit/DigestExtensions.swift
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
// DigestExtensions.swift - Copyright 2022 SwifterSwift
// DigestExtensions.swift - Copyright 2023 SwifterSwift

#if canImport(CryptoKit)
import CryptoKit

@available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *)
public extension Digest {

// MARK: - Properties

/// SwifterSwift: Hexadecimal value string (read-only, Complexity: O(N), _N_ being the amount of bytes.)
var hexString: String {
var result = ""
for byte in self.makeIterator() {
for byte in makeIterator() {
result += String(format: "%02X", byte)
}
return result
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// DispatchQueueExtensions.swift - Copyright 2020 SwifterSwift
// DispatchQueueExtensions.swift - Copyright 2023 SwifterSwift

#if canImport(Dispatch)
import Dispatch
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwifterSwift/Foundation/CalendarExtensions.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// CalendarExtensions.swift - Copyright 2020 SwifterSwift
// CalendarExtensions.swift - Copyright 2023 SwifterSwift

#if canImport(Foundation)
import Foundation
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwifterSwift/Foundation/DataExtensions.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// DataExtensions.swift - Copyright 2020 SwifterSwift
// DataExtensions.swift - Copyright 2023 SwifterSwift

#if canImport(Foundation)
import Foundation
Expand Down
17 changes: 11 additions & 6 deletions Sources/SwifterSwift/Foundation/DateExtensions.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// DateExtensions.swift - Copyright 2022 SwifterSwift
// DateExtensions.swift - Copyright 2023 SwifterSwift

#if canImport(Foundation)
import Foundation
Expand Down Expand Up @@ -247,7 +247,8 @@ public extension Date {
}
set {
#if targetEnvironment(macCatalyst)
// The `Calendar` implementation in `macCatalyst` does not know that a nanosecond is 1/1,000,000,000th of a second
// The `Calendar` implementation in `macCatalyst` does not know that a nanosecond is 1/1,000,000,000th of a
// second
let allowedRange = 0..<1_000_000_000
#else
let allowedRange = calendar.range(of: .nanosecond, in: .second, for: self)!
Expand Down Expand Up @@ -277,7 +278,8 @@ public extension Date {
set {
let nanoSeconds = newValue * 1_000_000
#if targetEnvironment(macCatalyst)
// The `Calendar` implementation in `macCatalyst` does not know that a nanosecond is 1/1,000,000,000th of a second
// The `Calendar` implementation in `macCatalyst` does not know that a nanosecond is 1/1,000,000,000th of a
// second
let allowedRange = 0..<1_000_000_000
#else
let allowedRange = calendar.range(of: .nanosecond, in: .second, for: self)!
Expand Down Expand Up @@ -548,7 +550,8 @@ public extension Date {
switch component {
case .nanosecond:
#if targetEnvironment(macCatalyst)
// The `Calendar` implementation in `macCatalyst` does not know that a nanosecond is 1/1,000,000,000th of a second
// The `Calendar` implementation in `macCatalyst` does not know that a nanosecond is 1/1,000,000,000th of a
// second
let allowedRange = 0..<1_000_000_000
#else
let allowedRange = calendar.range(of: .nanosecond, in: .second, for: self)!
Expand Down Expand Up @@ -922,7 +925,8 @@ public extension Date {
.timeIntervalSinceReferenceDate))
}

/// SwifterSwift: Returns a random date within the specified range, using the given generator as a source for randomness.
/// SwifterSwift: Returns a random date within the specified range, using the given generator as a source for
/// randomness.
///
/// - Parameters:
/// - range: The range in which to create a random date. `range` must not be empty.
Expand All @@ -935,7 +939,8 @@ public extension Date {
using: &generator))
}

/// SwifterSwift: Returns a random date within the specified range, using the given generator as a source for randomness.
/// SwifterSwift: Returns a random date within the specified range, using the given generator as a source for
/// randomness.
///
/// - Parameters:
/// - range: The range in which to create a random date.
Expand Down
5 changes: 3 additions & 2 deletions Sources/SwifterSwift/Foundation/FileManagerExtensions.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// FileManagerExtensions.swift - Copyright 2020 SwifterSwift
// FileManagerExtensions.swift - Copyright 2023 SwifterSwift

#if canImport(Foundation)
import Foundation
Expand Down Expand Up @@ -50,7 +50,8 @@ public extension FileManager {
}
#endif

/// SwifterSwift: Creates a unique directory for saving temporary files. The directory can be used to create multiple temporary files used for a common purpose.
/// SwifterSwift: Creates a unique directory for saving temporary files. The directory can be used to create
/// multiple temporary files used for a common purpose.
///
/// let tempDirectory = try fileManager.createTemporaryDirectory()
/// let tempFile1URL = tempDirectory.appendingPathComponent(ProcessInfo().globallyUniqueString)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwifterSwift/Foundation/LocaleExtensions.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// LocaleExtensions.swift - Copyright 2020 SwifterSwift
// LocaleExtensions.swift - Copyright 2023 SwifterSwift

#if canImport(Foundation)
import Foundation
Expand Down
3 changes: 2 additions & 1 deletion Sources/SwifterSwift/Foundation/MeasurementExtensions.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// MeasurementExtensions.swift - Copyright 2021 SwifterSwift
// MeasurementExtensions.swift - Copyright 2023 SwifterSwift

#if canImport(Foundation)
import Foundation

// MARK: - Methods

@available(OSX 10.12, tvOS 10.0, watchOS 3.0, *)
public extension Measurement where UnitType == UnitAngle {
/// SwifterSwift: Create a `Measurement` for an angle with a specified value in degrees.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// NSAttributedStringExtensions.swift - Copyright 2020 SwifterSwift
// NSAttributedStringExtensions.swift - Copyright 2023 SwifterSwift

#if canImport(Foundation)
import Foundation
Expand Down Expand Up @@ -103,7 +103,8 @@ public extension NSAttributedString {
/// - Parameters:
/// - attributes: Dictionary of attributes.
/// - pattern: a regular expression to target.
/// - options: The regular expression options that are applied to the expression during matching. See NSRegularExpression.Options for possible values.
/// - options: The regular expression options that are applied to the expression during matching. See
/// NSRegularExpression.Options for possible values.
/// - Returns: An NSAttributedString with attributes applied to substrings matching the pattern.
func applying(attributes: [Key: Any],
toRangesMatching pattern: String,
Expand Down Expand Up @@ -148,7 +149,8 @@ public extension NSAttributedString {
lhs = string
}

/// SwifterSwift: Add a NSAttributedString to another NSAttributedString and return a new NSAttributedString instance.
/// SwifterSwift: Add a NSAttributedString to another NSAttributedString and return a new NSAttributedString
/// instance.
///
/// - Parameters:
/// - lhs: NSAttributedString to add.
Expand All @@ -169,7 +171,8 @@ public extension NSAttributedString {
lhs += NSAttributedString(string: rhs)
}

/// SwifterSwift: Add a NSAttributedString to another NSAttributedString and return a new NSAttributedString instance.
/// SwifterSwift: Add a NSAttributedString to another NSAttributedString and return a new NSAttributedString
/// instance.
///
/// - Parameters:
/// - lhs: NSAttributedString to add.
Expand All @@ -181,7 +184,8 @@ public extension NSAttributedString {
}

public extension Array where Element: NSAttributedString {
/// SwifterSwift: Returns a new `NSAttributedString` by concatenating the elements of the sequence, adding the given separator between each element.
/// SwifterSwift: Returns a new `NSAttributedString` by concatenating the elements of the sequence, adding the given
/// separator between each element.
///
/// - Parameter separator: An `NSAttributedString` to add between the elements of the sequence.
/// - Returns: NSAttributedString with applied attributes.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// NSPredicateExtensions.swift - Copyright 2020 SwifterSwift
// NSPredicateExtensions.swift - Copyright 2023 SwifterSwift

#if canImport(Foundation)
import Foundation
Expand Down
Loading