From 3169853e65355ffea888aa3b4a4d587292943c43 Mon Sep 17 00:00:00 2001 From: Prachi Gauriar Date: Thu, 19 Mar 2026 00:27:16 -0400 Subject: [PATCH] Fix lint warnings in Xcode 26.4 RC1 --- Scripts/format | 13 ++++++++++ .../CollectionGeneration.swift | 8 +++--- .../BinaryFloatingPoint+Random.swift | 4 +-- .../Random Value Generation/Date+Random.swift | 8 +++--- .../Optional+Random.swift | 2 +- .../RandomValueGenerating.swift | 26 +++++++++---------- .../String+Random.swift | 12 ++++----- .../Random Value Generation/URL+Random.swift | 4 +-- .../URLComponents+Random.swift | 6 ++--- .../URLQueryItem+Random.swift | 6 ++--- .../Random Value Generation/UUID+Random.swift | 2 +- Sources/DevTesting/Stubbing/Stub.swift | 12 ++++----- .../RandomValueGeneratingTests.swift | 10 +++---- .../URL+RandomTests.swift | 6 ++--- .../URLComponents+RandomTests.swift | 4 +-- .../DevTestingTests/Stubbing/StubTests.swift | 8 +++--- 16 files changed, 72 insertions(+), 59 deletions(-) create mode 100755 Scripts/format diff --git a/Scripts/format b/Scripts/format new file mode 100755 index 0000000..d762974 --- /dev/null +++ b/Scripts/format @@ -0,0 +1,13 @@ +#!/bin/bash + +# Get the directory where this script is located +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Go to the repository root (one level up from Scripts) +REPO_ROOT="$(dirname "$SCRIPT_DIR")" + +# Run swift format with --in-place to fix formatting issues +swift format --in-place --recursive \ + "$REPO_ROOT/Packages/" \ + "$REPO_ROOT/Sources/" \ + "$REPO_ROOT/Tests/" diff --git a/Sources/DevTesting/Collection Generation/CollectionGeneration.swift b/Sources/DevTesting/Collection Generation/CollectionGeneration.swift index dc67fc0..bbbb9a8 100644 --- a/Sources/DevTesting/Collection Generation/CollectionGeneration.swift +++ b/Sources/DevTesting/Collection Generation/CollectionGeneration.swift @@ -15,7 +15,7 @@ extension Array { /// - elementGenerator: A closure that generates array elements. public init( count: Int, - elementGenerator: () throws(ErrorType) -> Element + elementGenerator: () throws(ErrorType) -> Element, ) throws(ErrorType) where ErrorType: Error { try self.init(count: count) { (_) throws(ErrorType) in try elementGenerator() @@ -31,7 +31,7 @@ extension Array { /// generated. public init( count: Int, - elementGenerator: (Int) throws(ErrorType) -> Element + elementGenerator: (Int) throws(ErrorType) -> Element, ) throws(ErrorType) where ErrorType: Error { self.init() reserveCapacity(count) @@ -56,7 +56,7 @@ extension Dictionary { /// - keyPairGenerator: A closure that generates key-value pairs. public init( count: Int, - keyPairGenerator: () throws(ErrorType) -> (Key, Value) + keyPairGenerator: () throws(ErrorType) -> (Key, Value), ) throws(ErrorType) where ErrorType: Error { self.init(minimumCapacity: count) @@ -79,7 +79,7 @@ extension Set { /// - elementGenerator: A closure that generates set elements. public init( count: Int, - elementGenerator: () throws(ErrorType) -> Element + elementGenerator: () throws(ErrorType) -> Element, ) throws(ErrorType) where ErrorType: Error { self.init(minimumCapacity: count) diff --git a/Sources/DevTesting/Random Value Generation/BinaryFloatingPoint+Random.swift b/Sources/DevTesting/Random Value Generation/BinaryFloatingPoint+Random.swift index c1d6441..94266fd 100644 --- a/Sources/DevTesting/Random Value Generation/BinaryFloatingPoint+Random.swift +++ b/Sources/DevTesting/Random Value Generation/BinaryFloatingPoint+Random.swift @@ -22,7 +22,7 @@ extension BinaryFloatingPoint where RawSignificand: FixedWidthInteger { /// - generator: The random number generator to use when creating the new random value. public static func randomPrintable( in range: Range, - using generator: inout some RandomNumberGenerator + using generator: inout some RandomNumberGenerator, ) -> Self { let subdivisions = 256 @@ -49,7 +49,7 @@ extension BinaryFloatingPoint where RawSignificand: FixedWidthInteger { /// - generator: The random number generator to use when creating the new random value. public static func randomPrintable( in range: ClosedRange, - using generator: inout some RandomNumberGenerator + using generator: inout some RandomNumberGenerator, ) -> Self { let subdivisions = 256 diff --git a/Sources/DevTesting/Random Value Generation/Date+Random.swift b/Sources/DevTesting/Random Value Generation/Date+Random.swift index 7425ca5..b9b7b98 100644 --- a/Sources/DevTesting/Random Value Generation/Date+Random.swift +++ b/Sources/DevTesting/Random Value Generation/Date+Random.swift @@ -16,14 +16,14 @@ extension Date { /// - Returns: A random date within the bounds of range. public static func random( in range: Range, - using generator: inout some RandomNumberGenerator + using generator: inout some RandomNumberGenerator, ) -> Date { let lowerBound = range.lowerBound.timeIntervalSinceReferenceDate let upperBound = range.upperBound.timeIntervalSinceReferenceDate return Date( timeIntervalSinceReferenceDate: .randomPrintable( in: lowerBound ..< upperBound, - using: &generator + using: &generator, ) ) } @@ -37,14 +37,14 @@ extension Date { /// - Returns: A random date within the bounds of range. public static func random( in range: ClosedRange, - using generator: inout some RandomNumberGenerator + using generator: inout some RandomNumberGenerator, ) -> Date { let lowerBound = range.lowerBound.timeIntervalSinceReferenceDate let upperBound = range.upperBound.timeIntervalSinceReferenceDate return Date( timeIntervalSinceReferenceDate: .randomPrintable( in: lowerBound ... upperBound, - using: &generator + using: &generator, ) ) } diff --git a/Sources/DevTesting/Random Value Generation/Optional+Random.swift b/Sources/DevTesting/Random Value Generation/Optional+Random.swift index 404a4c9..68219f6 100644 --- a/Sources/DevTesting/Random Value Generation/Optional+Random.swift +++ b/Sources/DevTesting/Random Value Generation/Optional+Random.swift @@ -16,7 +16,7 @@ extension Optional { /// - generator: The random number generator to use when creating the new random optional. public static func random( _ value: @autoclosure () -> Wrapped, - using generator: inout some RandomNumberGenerator + using generator: inout some RandomNumberGenerator, ) -> Self { return Bool.random(using: &generator) ? value() : nil } diff --git a/Sources/DevTesting/Random Value Generation/RandomValueGenerating.swift b/Sources/DevTesting/Random Value Generation/RandomValueGenerating.swift index dcf456b..a256b1a 100644 --- a/Sources/DevTesting/Random Value Generation/RandomValueGenerating.swift +++ b/Sources/DevTesting/Random Value Generation/RandomValueGenerating.swift @@ -151,7 +151,7 @@ extension RandomValueGenerating { public mutating func randomData(count: Int? = nil) -> Data { return Data.random( count: count ?? randomInt(in: 16 ... 128), - using: &randomNumberGenerator + using: &randomNumberGenerator, ) } @@ -191,7 +191,7 @@ extension RandomValueGenerating { /// - range: The half-open range in which to create a random value. public mutating func random( _ type: FloatingPoint.Type, - in range: Range + in range: Range, ) -> FloatingPoint where FloatingPoint: BinaryFloatingPoint, FloatingPoint.RawSignificand: FixedWidthInteger { return FloatingPoint.randomPrintable(in: range, using: &randomNumberGenerator) @@ -217,7 +217,7 @@ extension RandomValueGenerating { /// - range: The closed range in which to create a random value. public mutating func random( _ type: FloatingPoint.Type, - in range: ClosedRange + in range: ClosedRange, ) -> FloatingPoint where FloatingPoint: BinaryFloatingPoint, FloatingPoint.RawSignificand: FixedWidthInteger { return FloatingPoint.randomPrintable(in: range, using: &randomNumberGenerator) @@ -243,7 +243,7 @@ extension RandomValueGenerating { /// - range: The half-open range in which to create a random value. public mutating func random( _ type: Integer.Type, - in range: Range + in range: Range, ) -> Integer where Integer: FixedWidthInteger { return Integer.random(in: range, using: &randomNumberGenerator) @@ -269,7 +269,7 @@ extension RandomValueGenerating { /// - range: The closed range in which to create a random value. public mutating func random( _ type: Integer.Type, - in range: ClosedRange + in range: ClosedRange, ) -> Integer where Integer: FixedWidthInteger { return Integer.random(in: range, using: &randomNumberGenerator) @@ -310,7 +310,7 @@ extension RandomValueGenerating { public mutating func randomAlphanumericString(count: Int? = nil) -> String { return String.randomAlphanumeric( count: count ?? Int.random(in: 5 ... 10, using: &randomNumberGenerator), - using: &randomNumberGenerator + using: &randomNumberGenerator, ) } @@ -324,7 +324,7 @@ extension RandomValueGenerating { public mutating func randomBasicLatinString(count: Int? = nil) -> String { return String.randomBasicLatin( count: count ?? Int.random(in: 5 ... 10, using: &randomNumberGenerator), - using: &randomNumberGenerator + using: &randomNumberGenerator, ) } @@ -339,12 +339,12 @@ extension RandomValueGenerating { /// chosen. public mutating func randomString( withCharactersFrom characters: some Collection, - count: Int? = nil + count: Int? = nil, ) -> String { return String.random( withCharactersFrom: characters, count: count ?? Int.random(in: 5 ... 10, using: &randomNumberGenerator), - using: &randomNumberGenerator + using: &randomNumberGenerator, ) } @@ -370,12 +370,12 @@ extension RandomValueGenerating { /// include query items or not. public mutating func randomURL( includeFragment: Bool? = nil, - includeQueryItems: Bool? = nil + includeQueryItems: Bool? = nil, ) -> URL { return URL.random( includeFragment: includeFragment, includeQueryItems: includeQueryItems, - using: &randomNumberGenerator + using: &randomNumberGenerator, ) } @@ -391,12 +391,12 @@ extension RandomValueGenerating { /// include query items or not. public mutating func randomURLComponents( includeFragment: Bool? = nil, - includeQueryItems: Bool? = nil + includeQueryItems: Bool? = nil, ) -> URLComponents { return URLComponents.random( includeFragment: includeFragment, includeQueryItems: includeQueryItems, - using: &randomNumberGenerator + using: &randomNumberGenerator, ) } diff --git a/Sources/DevTesting/Random Value Generation/String+Random.swift b/Sources/DevTesting/Random Value Generation/String+Random.swift index a69fdb5..acf6e9e 100644 --- a/Sources/DevTesting/Random Value Generation/String+Random.swift +++ b/Sources/DevTesting/Random Value Generation/String+Random.swift @@ -18,7 +18,7 @@ extension String { public static func random( withCharactersFrom characters: some Collection, count: Int, - using generator: inout some RandomNumberGenerator + using generator: inout some RandomNumberGenerator, ) -> String { precondition(!characters.isEmpty || count == 0, "count must be 0 if characters is empty") guard count > 0 else { @@ -39,14 +39,14 @@ extension String { /// - generator: The random number generator to use when creating the new random string. public static func randomAlphanumeric( count: Int, - using generator: inout some RandomNumberGenerator + using generator: inout some RandomNumberGenerator, ) -> String { return random( withCharactersFrom: characters( - fromUnicodeScalarRanges: 0x30 ... 0x39, 0x41 ... 0x5a, 0x61 ... 0x7a + fromUnicodeScalarRanges: 0x30 ... 0x39, 0x41 ... 0x5a, 0x61 ... 0x7a, ), count: count, - using: &generator + using: &generator, ) } @@ -65,12 +65,12 @@ extension String { /// - generator: The random number generator to use when creating the new random string. public static func randomBasicLatin( count: Int, - using generator: inout some RandomNumberGenerator + using generator: inout some RandomNumberGenerator, ) -> String { return random( withCharactersFrom: characters(fromUnicodeScalarRanges: 0x20 ... 0x7e), count: count, - using: &generator + using: &generator, ) } diff --git a/Sources/DevTesting/Random Value Generation/URL+Random.swift b/Sources/DevTesting/Random Value Generation/URL+Random.swift index 02a8b5d..e31788e 100644 --- a/Sources/DevTesting/Random Value Generation/URL+Random.swift +++ b/Sources/DevTesting/Random Value Generation/URL+Random.swift @@ -22,12 +22,12 @@ extension URL { public static func random( includeFragment: Bool? = nil, includeQueryItems: Bool? = nil, - using generator: inout some RandomNumberGenerator + using generator: inout some RandomNumberGenerator, ) -> URL { return URLComponents.random( includeFragment: includeFragment, includeQueryItems: includeQueryItems, - using: &generator + using: &generator, ).url! } } diff --git a/Sources/DevTesting/Random Value Generation/URLComponents+Random.swift b/Sources/DevTesting/Random Value Generation/URLComponents+Random.swift index 1a37bfa..50875cb 100644 --- a/Sources/DevTesting/Random Value Generation/URLComponents+Random.swift +++ b/Sources/DevTesting/Random Value Generation/URLComponents+Random.swift @@ -30,7 +30,7 @@ extension URLComponents { public static func random( includeFragment: Bool? = nil, includeQueryItems: Bool? = nil, - using generator: inout some RandomNumberGenerator + using generator: inout some RandomNumberGenerator, ) -> URLComponents { var urlComponents = URLComponents() @@ -47,7 +47,7 @@ extension URLComponents { let pathComponents = Array(count: Int.random(in: 1 ... 5, using: &generator)) { String.randomAlphanumeric( count: Int.random(in: 1 ... 5, using: &generator), - using: &generator + using: &generator, ) } urlComponents.path = "/\(pathComponents.joined(separator: "/"))" @@ -56,7 +56,7 @@ extension URLComponents { if includeFragment ?? Bool.random(using: &generator) { urlComponents.fragment = String.randomAlphanumeric( count: Int.random(in: 3 ... 5, using: &generator), - using: &generator + using: &generator, ) } diff --git a/Sources/DevTesting/Random Value Generation/URLQueryItem+Random.swift b/Sources/DevTesting/Random Value Generation/URLQueryItem+Random.swift index 6b69e9f..89e7da5 100644 --- a/Sources/DevTesting/Random Value Generation/URLQueryItem+Random.swift +++ b/Sources/DevTesting/Random Value Generation/URLQueryItem+Random.swift @@ -18,14 +18,14 @@ extension URLQueryItem { return URLQueryItem( name: .randomAlphanumeric( count: Int.random(in: 3 ... 10, using: &generator), - using: &generator + using: &generator, ), value: Int.random(in: 0 ..< 10, using: &generator) == 0 ? nil : .randomAlphanumeric( count: Int.random(in: 3 ... 10, using: &generator), - using: &generator - ) + using: &generator, + ), ) } } diff --git a/Sources/DevTesting/Random Value Generation/UUID+Random.swift b/Sources/DevTesting/Random Value Generation/UUID+Random.swift index eeb0d3b..b8c8a97 100644 --- a/Sources/DevTesting/Random Value Generation/UUID+Random.swift +++ b/Sources/DevTesting/Random Value Generation/UUID+Random.swift @@ -25,7 +25,7 @@ extension UUID { return UUID( uuid: ( bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], modifiedByte6, bytes[7], - modifiedByte8, bytes[9], bytes[10], bytes[11], bytes[12], bytes[13], bytes[14], bytes[15] + modifiedByte8, bytes[9], bytes[10], bytes[11], bytes[12], bytes[13], bytes[14], bytes[15], ) ) } diff --git a/Sources/DevTesting/Stubbing/Stub.swift b/Sources/DevTesting/Stubbing/Stub.swift index 21740f5..b152714 100644 --- a/Sources/DevTesting/Stubbing/Stub.swift +++ b/Sources/DevTesting/Stubbing/Stub.swift @@ -52,12 +52,12 @@ public final class ThrowingStub where ErrorTyp /// - resultQueue: A queue of call results to use. If empty, `defaultResult` is used. public init( defaultResult: Result, - resultQueue: [Result] = [] + resultQueue: [Result] = [], ) { self.mutableProperties = .init( uncheckedState: .init( defaultResult: defaultResult, - resultQueue: resultQueue + resultQueue: resultQueue, ) ) } @@ -146,7 +146,7 @@ extension ThrowingStub { /// - resultQueue: A queue of call results to use. If empty, `defaultResult` is used. public convenience init( defaultReturnValue: ReturnType, - resultQueue: [Result] = [] + resultQueue: [Result] = [], ) { self.init(defaultResult: .success(defaultReturnValue), resultQueue: resultQueue) } @@ -159,7 +159,7 @@ extension ThrowingStub { /// - resultQueue: A queue of call results to use. If empty, `defaultResult` is used. public convenience init( defaultError: ErrorType, - resultQueue: [Result] = [] + resultQueue: [Result] = [], ) { self.init(defaultResult: .failure(defaultError), resultQueue: resultQueue) } @@ -204,7 +204,7 @@ extension ThrowingStub where ReturnType == Void { public convenience init(defaultError: ErrorType?, errorQueue: [ErrorType?] = []) { self.init( defaultResult: defaultError.map(Result.failure(_:)) ?? .success(()), - resultQueue: errorQueue.map { $0.map(Result.failure(_:)) ?? .success(()) } + resultQueue: errorQueue.map { $0.map(Result.failure(_:)) ?? .success(()) }, ) } @@ -273,7 +273,7 @@ extension ThrowingStub where ErrorType == Never { public convenience init(defaultReturnValue: ReturnType, returnValueQueue: [ReturnType]) { self.init( defaultResult: .success(defaultReturnValue), - resultQueue: returnValueQueue.map(Result.success(_:)) + resultQueue: returnValueQueue.map(Result.success(_:)), ) } diff --git a/Tests/DevTestingTests/Random Value Generation/RandomValueGeneratingTests.swift b/Tests/DevTestingTests/Random Value Generation/RandomValueGeneratingTests.swift index c972e90..cc132c3 100644 --- a/Tests/DevTestingTests/Random Value Generation/RandomValueGeneratingTests.swift +++ b/Tests/DevTestingTests/Random Value Generation/RandomValueGeneratingTests.swift @@ -352,7 +352,7 @@ struct RandomValueGeneratingTests { let expectedString = String.random( withCharactersFrom: "πŸ€“πŸ‘ΎπŸ’€πŸ’©", count: Int.random(in: 5 ... 10, using: &rng), - using: &rng + using: &rng, ) #expect(randomString == expectedString) } @@ -399,13 +399,13 @@ struct RandomValueGeneratingTests { for _ in iterationRange { let randomURL = generator.randomURL( includeFragment: includeFragment, - includeQueryItems: includeQueryItems + includeQueryItems: includeQueryItems, ) let expectedURL = URL.random( includeFragment: includeFragment, includeQueryItems: includeQueryItems, - using: &rng + using: &rng, ) #expect(randomURL == expectedURL) @@ -430,13 +430,13 @@ struct RandomValueGeneratingTests { for _ in iterationRange { let randomURLComponents = generator.randomURLComponents( includeFragment: includeFragment, - includeQueryItems: includeQueryItems + includeQueryItems: includeQueryItems, ) let expectedURLComponents = URLComponents.random( includeFragment: includeFragment, includeQueryItems: includeQueryItems, - using: &rng + using: &rng, ) #expect(randomURLComponents == expectedURLComponents) diff --git a/Tests/DevTestingTests/Random Value Generation/URL+RandomTests.swift b/Tests/DevTestingTests/Random Value Generation/URL+RandomTests.swift index 4cd355c..46b67a4 100644 --- a/Tests/DevTestingTests/Random Value Generation/URL+RandomTests.swift +++ b/Tests/DevTestingTests/Random Value Generation/URL+RandomTests.swift @@ -25,7 +25,7 @@ struct URL_RandomTests { ) func randomReturnsIsSameAsURLComponents( includeFragment: Bool? = nil, - includeQueryItems: Bool? = nil + includeQueryItems: Bool? = nil, ) throws { let seed = UInt64.random(in: 0 ... .max) @@ -35,13 +35,13 @@ struct URL_RandomTests { let url = URL.random( includeFragment: includeFragment, includeQueryItems: includeQueryItems, - using: &rng1 + using: &rng1, ) let expectedURL = URLComponents.random( includeFragment: includeFragment, includeQueryItems: includeQueryItems, - using: &rng2 + using: &rng2, ).url #expect(url == expectedURL) diff --git a/Tests/DevTestingTests/Random Value Generation/URLComponents+RandomTests.swift b/Tests/DevTestingTests/Random Value Generation/URLComponents+RandomTests.swift index 1595885..d1f1aff 100644 --- a/Tests/DevTestingTests/Random Value Generation/URLComponents+RandomTests.swift +++ b/Tests/DevTestingTests/Random Value Generation/URLComponents+RandomTests.swift @@ -55,7 +55,7 @@ struct URLComponents_RandomTests { @Test(arguments: [(false, false), (false, true), (true, false), (true, true)]) func randomReturnsCorrectComponentsWhenIncludeArgumentsAreNonNil( includeFragment: Bool, - includeQueryItems: Bool + includeQueryItems: Bool, ) throws { let iterationCount = 10 var rng = SystemRandomNumberGenerator() @@ -64,7 +64,7 @@ struct URLComponents_RandomTests { let components = URLComponents.random( includeFragment: includeFragment, includeQueryItems: includeQueryItems, - using: &rng + using: &rng, ) // The properties should be non-nil if and only if the corresponding boolean is true diff --git a/Tests/DevTestingTests/Stubbing/StubTests.swift b/Tests/DevTestingTests/Stubbing/StubTests.swift index 72fe9f9..1a3c6ce 100644 --- a/Tests/DevTestingTests/Stubbing/StubTests.swift +++ b/Tests/DevTestingTests/Stubbing/StubTests.swift @@ -19,7 +19,7 @@ struct StubTests { let stub = ThrowingStub( defaultResult: defaultResult, - resultQueue: resultQueue + resultQueue: resultQueue, ) #expect(stub.defaultResult == defaultResult) @@ -37,7 +37,7 @@ struct StubTests { let stub = ThrowingStub( defaultReturnValue: 10, - resultQueue: resultQueue + resultQueue: resultQueue, ) #expect(stub.defaultResult == .success(defaultReturnValue)) @@ -55,7 +55,7 @@ struct StubTests { let stub = ThrowingStub( defaultError: defaultError, - resultQueue: resultQueue + resultQueue: resultQueue, ) #expect(stub.defaultResult == .failure(defaultError)) @@ -89,7 +89,7 @@ struct StubTests { let stub = ThrowingStub( defaultResult: defaultResult, - resultQueue: resultQueue + resultQueue: resultQueue, ) let arguments = (0 ... 5).map(String.init(_:))