Skip to content

Commit 63cac55

Browse files
committed
Remove usage of '.init'
1 parent b4d1c8c commit 63cac55

38 files changed

+456
-451
lines changed

sources/Utils.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ extension Array where Element:Hashable {
6868
/// In case of two array element with the same hash value, the closure is executed and the generated error is thrown.
6969
/// - parameter error: The error being thrown on hash value collisions.
7070
func lookupDictionary(onCollision error: ()->Swift.Error) throws -> [Int:Int] {
71-
var lookup: [Int:Int] = .init(minimumCapacity: self.count)
71+
var lookup: [Int:Int] = Dictionary(minimumCapacity: self.count)
7272
for (index, header) in self.enumerated() {
7373
let hash = header.hashValue
7474
guard case .none = lookup.updateValue(index, forKey: hash) else { throw error() }

sources/declarative/decodable/Decoder.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import Foundation
99

1010
/// Creates a CSV decoder with tthe default configuration values.
1111
/// - parameter configuration: Configuration values for the decoding process.
12-
public init(configuration: Configuration = .init()) {
12+
public init(configuration: Configuration = Configuration()) {
1313
self._configuration = configuration
14-
self.userInfo = .init()
14+
self.userInfo = Dictionary()
1515
}
1616

1717
/// Creates a CSV decoder and passes the default configuration values to the closure.

sources/declarative/decodable/DecoderConfiguration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ extension CSVDecoder {
2222

2323
/// Designated initializer setting the default values.
2424
public init() {
25-
self.readerConfiguration = .init()
25+
self.readerConfiguration = CSVReader.Configuration()
2626
self.nilStrategy = .empty
2727
self.boolStrategy = .insensitive
2828
self.nonConformingFloatStrategy = .throw

sources/declarative/decodable/DecoderLazy.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ extension CSVDecoder.Lazy {
7777
fileprivate extension CSVDecoder.Error {
7878
/// Error raised when the end of the file has been reached unexpectedly.
7979
static func _unexpectedEnd() -> CSVError<CSVDecoder> {
80-
.init(.invalidPath,
81-
reason: "There are no more rows to decode. The file is at the end.",
82-
help: "Use next() or decodeIfPresent(_:) instead of decode(_:) if you are unsure where the file ends.")
80+
CSVError(.invalidPath,
81+
reason: "There are no more rows to decode. The file is at the end.",
82+
help: "Use next() or decodeIfPresent(_:) instead of decode(_:) if you are unsure where the file ends.")
8383
}
8484
}

sources/declarative/decodable/containers/KeyedDecodingContainer.swift

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -199,65 +199,65 @@ extension ShadowDecoder.KeyedContainer {
199199
}
200200

201201
//extension ShadowDecoder.KeyedContainer {
202-
// func decodeIfPresent(_ type: String.Type, forKey key: Key) throws -> String? {
203-
// try? self.decode(String.self, forKey: key)
204-
// }
202+
// func decodeIfPresent(_ type: String.Type, forKey key: Key) throws -> String? {
203+
// try? self.decode(String.self, forKey: key)
204+
// }
205205
//
206-
// func decodeIfPresent(_ type: Bool.Type, forKey key: Key) throws -> Bool? {
207-
// try? self.decode(Bool.self, forKey: key)
208-
// }
206+
// func decodeIfPresent(_ type: Bool.Type, forKey key: Key) throws -> Bool? {
207+
// try? self.decode(Bool.self, forKey: key)
208+
// }
209209
//
210-
// func decodeIfPresent(_ type: Int.Type, forKey key: Key) throws -> Int? {
211-
// try? self.decode(Int.self, forKey: key)
212-
// }
210+
// func decodeIfPresent(_ type: Int.Type, forKey key: Key) throws -> Int? {
211+
// try? self.decode(Int.self, forKey: key)
212+
// }
213213
//
214-
// func decodeIfPresent(_ type: Int8.Type, forKey key: Key) throws -> Int8? {
215-
// try? self.decode(Int8.self, forKey: key)
216-
// }
214+
// func decodeIfPresent(_ type: Int8.Type, forKey key: Key) throws -> Int8? {
215+
// try? self.decode(Int8.self, forKey: key)
216+
// }
217217
//
218-
// func decodeIfPresent(_ type: Int16.Type, forKey key: Key) throws -> Int16? {
219-
// try? self.decode(Int16.self, forKey: key)
220-
// }
218+
// func decodeIfPresent(_ type: Int16.Type, forKey key: Key) throws -> Int16? {
219+
// try? self.decode(Int16.self, forKey: key)
220+
// }
221221
//
222-
// func decodeIfPresent(_ type: Int32.Type, forKey key: Key) throws -> Int32? {
223-
// try? self.decode(Int32.self, forKey: key)
224-
// }
222+
// func decodeIfPresent(_ type: Int32.Type, forKey key: Key) throws -> Int32? {
223+
// try? self.decode(Int32.self, forKey: key)
224+
// }
225225
//
226-
// func decodeIfPresent(_ type: Int64.Type, forKey key: Key) throws -> Int64? {
227-
// try? self.decode(Int64.self, forKey: key)
228-
// }
226+
// func decodeIfPresent(_ type: Int64.Type, forKey key: Key) throws -> Int64? {
227+
// try? self.decode(Int64.self, forKey: key)
228+
// }
229229
//
230-
// func decodeIfPresent(_ type: UInt.Type, forKey key: Key) throws -> UInt? {
231-
// try? self.decode(UInt.self, forKey: key)
232-
// }
230+
// func decodeIfPresent(_ type: UInt.Type, forKey key: Key) throws -> UInt? {
231+
// try? self.decode(UInt.self, forKey: key)
232+
// }
233233
//
234-
// func decodeIfPresent(_ type: UInt8.Type, forKey key: Key) throws -> UInt8? {
235-
// try? self.decode(UInt8.self, forKey: key)
236-
// }
234+
// func decodeIfPresent(_ type: UInt8.Type, forKey key: Key) throws -> UInt8? {
235+
// try? self.decode(UInt8.self, forKey: key)
236+
// }
237237
//
238-
// func decodeIfPresent(_ type: UInt16.Type, forKey key: Key) throws -> UInt16? {
239-
// try? self.decode(UInt16.self, forKey: key)
240-
// }
238+
// func decodeIfPresent(_ type: UInt16.Type, forKey key: Key) throws -> UInt16? {
239+
// try? self.decode(UInt16.self, forKey: key)
240+
// }
241241
//
242-
// func decodeIfPresent(_ type: UInt32.Type, forKey key: Key) throws -> UInt32? {
243-
// try? self.decode(UInt32.self, forKey: key)
244-
// }
242+
// func decodeIfPresent(_ type: UInt32.Type, forKey key: Key) throws -> UInt32? {
243+
// try? self.decode(UInt32.self, forKey: key)
244+
// }
245245
//
246-
// func decodeIfPresent(_ type: UInt64.Type, forKey key: Key) throws -> UInt64? {
247-
// try? self.decode(UInt64.self, forKey: key)
248-
// }
246+
// func decodeIfPresent(_ type: UInt64.Type, forKey key: Key) throws -> UInt64? {
247+
// try? self.decode(UInt64.self, forKey: key)
248+
// }
249249
//
250-
// func decodeIfPresent(_ type: Float.Type, forKey key: Key) throws -> Float? {
251-
// try? self.decode(Float.self, forKey: key)
252-
// }
250+
// func decodeIfPresent(_ type: Float.Type, forKey key: Key) throws -> Float? {
251+
// try? self.decode(Float.self, forKey: key)
252+
// }
253253
//
254-
// func decodeIfPresent(_ type: Double.Type, forKey key: Key) throws -> Double? {
255-
// try? self.decode(Double.self, forKey: key)
256-
// }
254+
// func decodeIfPresent(_ type: Double.Type, forKey key: Key) throws -> Double? {
255+
// try? self.decode(Double.self, forKey: key)
256+
// }
257257
//
258-
// func decodeIfPresent<T>(_ type: T.Type, forKey key: Key) throws -> T? where T:Decodable {
259-
// try? self.decode(T.self, forKey: key)
260-
// }
258+
// func decodeIfPresent<T>(_ type: T.Type, forKey key: Key) throws -> T? where T:Decodable {
259+
// try? self.decode(T.self, forKey: key)
260+
// }
261261
//}
262262

263263
// MARK: -
@@ -291,33 +291,33 @@ private extension ShadowDecoder.KeyedContainer {
291291
}
292292

293293
let decoder = ShadowDecoder(source: self._decoder.source, codingPath: codingPath)
294-
return .init(unsafeDecoder: decoder, rowIndex: index.row, fieldIndex: index.field)
294+
return ShadowDecoder.SingleValueContainer(unsafeDecoder: decoder, rowIndex: index.row, fieldIndex: index.field)
295295
}
296296
}
297297

298298
fileprivate extension CSVDecoder.Error {
299299
/// Error raised when a coding key representing a row within the CSV file cannot be transformed into an integer value.
300300
/// - parameter codingPath: The full decoding chain.
301301
static func _invalidRowKey(forKey key: CodingKey, codingPath: [CodingKey]) -> CSVError<CSVDecoder> {
302-
.init(.invalidPath,
303-
reason: "The coding key identifying a CSV row couldn't be transformed into an integer value.",
304-
help: "The provided coding key identifying a CSV row must implement `intValue`.",
305-
userInfo: ["Coding path": codingPath, "Key": key])
302+
CSVError(.invalidPath,
303+
reason: "The coding key identifying a CSV row couldn't be transformed into an integer value.",
304+
help: "The provided coding key identifying a CSV row must implement `intValue`.",
305+
userInfo: ["Coding path": codingPath, "Key": key])
306306
}
307307
/// Error raised when a keyed container is requested on an invalid coding path.
308308
/// - parameter codingPath: The full decoding chain.
309309
static func _invalidContainerRequest(forKey key: CodingKey, codingPath: [CodingKey]) -> CSVError<CSVDecoder> {
310-
.init(.invalidPath,
311-
reason: "A CSV doesn't support more than two nested decoding container.",
312-
help: "Don't ask for a nested container on the targeted key for this coding path.",
313-
userInfo: ["Coding path": codingPath, "Key": key])
310+
CSVError(.invalidPath,
311+
reason: "A CSV doesn't support more than two nested decoding container.",
312+
help: "Don't ask for a nested container on the targeted key for this coding path.",
313+
userInfo: ["Coding path": codingPath, "Key": key])
314314
}
315315
/// Error raised when a value is decoded, but a container was expected by the decoder.
316316
/// - parameter codingPath: The full decoding chain.
317317
static func _invalidNestedRequired(codingPath: [CodingKey]) -> CSVError<CSVDecoder> {
318-
.init(.invalidPath,
319-
reason: "A nested container is needed to decode CSV row values",
320-
help: "Request a nested container instead of trying to decode a value directly.",
321-
userInfo: ["Coding path": codingPath])
318+
CSVError(.invalidPath,
319+
reason: "A nested container is needed to decode CSV row values",
320+
help: "Request a nested container instead of trying to decode a value directly.",
321+
userInfo: ["Coding path": codingPath])
322322
}
323323
}

sources/declarative/decodable/containers/SingleValueDecodingContainer.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -280,25 +280,25 @@ fileprivate extension CSVDecoder.Error {
280280
/// Error raised when a coding key representing a row within the CSV file cannot be transformed into an integer value.
281281
/// - parameter codingPath: The whole coding path, including the invalid row key.
282282
static func _invalidRowKey(forKey key: CodingKey, codingPath: [CodingKey]) -> CSVError<CSVDecoder> {
283-
.init(.invalidPath,
284-
reason: "The coding key identifying a CSV row couldn't be transformed into an integer value.",
285-
help: "The provided coding key identifying a CSV row must implement `intValue`.",
286-
userInfo: ["Coding path": codingPath, "Key": key])
283+
CSVError(.invalidPath,
284+
reason: "The coding key identifying a CSV row couldn't be transformed into an integer value.",
285+
help: "The provided coding key identifying a CSV row must implement `intValue`.",
286+
userInfo: ["Coding path": codingPath, "Key": key])
287287
}
288288
/// Error raised when a single value container is requested on an invalid coding path.
289289
/// - parameter codingPath: The full chain of containers which generated this error.
290290
static func _invalidContainerRequest(codingPath: [CodingKey]) -> CSVError<CSVDecoder> {
291-
.init(.invalidPath,
292-
reason: "A CSV doesn't support more than two nested decoding containers.",
293-
help: "Don't ask for a single value encoding container on this coding path.",
294-
userInfo: ["Coding path": codingPath])
291+
CSVError(.invalidPath,
292+
reason: "A CSV doesn't support more than two nested decoding containers.",
293+
help: "Don't ask for a single value encoding container on this coding path.",
294+
userInfo: ["Coding path": codingPath])
295295
}
296296
/// Error raised when a value is decoded, but a container was expected by the decoder.
297297
static func _invalidNestedRequired(codingPath: [CodingKey]) -> CSVError<CSVDecoder> {
298-
.init(.invalidPath,
299-
reason: "A nested container is needed to decode CSV row values",
300-
help: "Request a nested container instead of trying to decode the value directly.",
301-
userInfo: ["Coding path": codingPath])
298+
CSVError(.invalidPath,
299+
reason: "A nested container is needed to decode CSV row values",
300+
help: "Request a nested container instead of trying to decode the value directly.",
301+
userInfo: ["Coding path": codingPath])
302302
}
303303
/// Error raised when transforming a `String` value into another type.
304304
/// - parameter value: The `String` value, which couldn't be transformed.

sources/declarative/decodable/containers/UnkeyedDecodingContainer.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -244,32 +244,32 @@ private extension ShadowDecoder.UnkeyedContainer {
244244
}
245245

246246
let decoder = ShadowDecoder(source: self._decoder.source, codingPath: codingPath)
247-
return .init(unsafeDecoder: decoder, rowIndex: index.row, fieldIndex: index.field)
247+
return ShadowDecoder.SingleValueContainer(unsafeDecoder: decoder, rowIndex: index.row, fieldIndex: index.field)
248248
}
249249
}
250250

251251
fileprivate extension CSVDecoder.Error {
252252
/// Error raised when a coding key representing a row within the CSV file cannot be transformed into an integer value.
253253
/// - parameter codingPath: The whole coding path, including the invalid row key.
254254
static func _invalidRowKey(forKey key: CodingKey, codingPath: [CodingKey]) -> CSVError<CSVDecoder> {
255-
.init(.invalidPath,
256-
reason: "The coding key identifying a CSV row couldn't be transformed into an integer value.",
257-
help: "The provided coding key identifying a CSV row must implement `intValue`.",
258-
userInfo: ["Coding path": codingPath, "Key": key])
255+
CSVError(.invalidPath,
256+
reason: "The coding key identifying a CSV row couldn't be transformed into an integer value.",
257+
help: "The provided coding key identifying a CSV row must implement `intValue`.",
258+
userInfo: ["Coding path": codingPath, "Key": key])
259259
}
260260
/// Error raised when a unkeyed container is requested on an invalid coding path.
261261
/// - parameter codingPath: The full chain of containers which generated this error.
262262
static func _invalidContainerRequest(codingPath: [CodingKey]) -> CSVError<CSVDecoder> {
263-
.init(.invalidPath,
264-
reason: "A CSV doesn't support more than two nested encoding container.",
265-
help: "Don't ask for a unkeyed decoding container on this coding path.",
266-
userInfo: ["Coding path": codingPath])
263+
CSVError(.invalidPath,
264+
reason: "A CSV doesn't support more than two nested encoding container.",
265+
help: "Don't ask for a unkeyed decoding container on this coding path.",
266+
userInfo: ["Coding path": codingPath])
267267
}
268268
/// Error raised when a value is decoded, but a container was expected by the decoder.
269269
static func _invalidNestedRequired(codingPath: [CodingKey]) -> CSVError<CSVDecoder> {
270-
.init(.invalidPath,
271-
reason: "A nested container is needed to decode at this coding path.",
272-
help: "Request a nested container instead of trying to decode a value directly.",
273-
userInfo: ["Coding path": codingPath])
270+
CSVError(.invalidPath,
271+
reason: "A nested container is needed to decode at this coding path.",
272+
help: "Request a nested container instead of trying to decode a value directly.",
273+
userInfo: ["Coding path": codingPath])
274274
}
275275
}

0 commit comments

Comments
 (0)