Skip to content

Commit b2c9ea8

Browse files
authored
[Runtime] Consistent style for initializing local variables (#31)
[Runtime] Consistent style for initializing local variables ### Motivation Move to a consistent style when initializing local variables, always use `let foo = Foo(...)` vs `let foo: Foo = .init(...)`. ### Modifications Updated all occurrences of the latter to use the former. ### Result Consistent local variable initialization. ### Test Plan All tests passed. Reviewed by: gjcairo, simonjbeaumont Builds: ✔︎ pull request validation (5.8) - Build finished. ✔︎ pull request validation (5.9) - Build finished. ✔︎ pull request validation (api breakage) - Build finished. ✔︎ pull request validation (docc test) - Build finished. ✔︎ pull request validation (integration test) - Build finished. ✔︎ pull request validation (nightly) - Build finished. ✔︎ pull request validation (soundness) - Build finished. #31
1 parent 5b5b5ef commit b2c9ea8

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

Sources/OpenAPIRuntime/Conversion/FoundationExtensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ extension Data {
2828
extension Request {
2929
/// Allows modifying the parsed query parameters of the request.
3030
mutating func mutateQuery(_ closure: (inout URLComponents) throws -> Void) rethrows {
31-
var urlComponents: URLComponents = .init()
31+
var urlComponents = URLComponents()
3232
if let query {
3333
urlComponents.percentEncodedQuery = query
3434
}

Sources/OpenAPIRuntime/Deprecated/Deprecated.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ extension Request {
498498
/// Allows modifying the parsed query parameters of the request.
499499
@available(*, deprecated)
500500
mutating func mutatingQuery(_ closure: (inout URLComponents) throws -> Void) rethrows {
501-
var urlComponents: URLComponents = .init()
501+
var urlComponents = URLComponents()
502502
if let query {
503503
urlComponents.percentEncodedQuery = query
504504
}

Tests/OpenAPIRuntimeTests/Conversion/Test_CodableExtensions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ final class Test_CodableExtensions: Test_Runtime {
2121
}
2222

2323
var testEncoder: JSONEncoder {
24-
let encoder: JSONEncoder = .init()
24+
let encoder = JSONEncoder()
2525
encoder.outputFormatting = [.prettyPrinted, .sortedKeys]
2626
return encoder
2727
}
@@ -187,7 +187,7 @@ final class Test_CodableExtensions: Test_Runtime {
187187

188188
struct Foo: Encodable {
189189
var bar: String
190-
var additionalProperties: OpenAPIObjectContainer = .init()
190+
var additionalProperties = OpenAPIObjectContainer()
191191

192192
enum CodingKeys: String, CodingKey {
193193
case bar

Tests/OpenAPIRuntimeTests/Test_Runtime.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Test_Runtime: XCTestCase {
3737
}
3838

3939
var testComponents: URLComponents {
40-
var components: URLComponents = .init()
40+
var components = URLComponents()
4141
components.path = "/api"
4242
return components
4343
}

0 commit comments

Comments
 (0)