Skip to content

Commit 7e7c382

Browse files
g-cqdclaude
andcommitted
style: fix swift-format lint warnings
- Break long lines under 120-char limit - Fix indentation in KeyedEncodingContainer initializers - Fix line breaks in multiline expressions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9226af1 commit 7e7c382

3 files changed

Lines changed: 31 additions & 21 deletions

File tree

Sources/CSVCoder/Encoder/CSVRowEncoder.swift

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,14 @@ nonisolated struct CSVKeyedEncodingContainer<Key: CodingKey>: KeyedEncodingConta
234234
) -> KeyedEncodingContainer<NestedKey> {
235235
switch configuration.nestedTypeEncodingStrategy {
236236
case .error:
237-
return KeyedEncodingContainer(CSVPoisonKeyedEncodingContainer<NestedKey>(
238-
error: CSVEncodingError.unsupportedType(
239-
"Nested containers are not supported in CSV. Configure nestedTypeEncodingStrategy to enable."
240-
),
241-
codingPath: codingPath + [key],
242-
))
237+
return KeyedEncodingContainer(
238+
CSVPoisonKeyedEncodingContainer<NestedKey>(
239+
error: CSVEncodingError.unsupportedType(
240+
"Nested containers are not supported in CSV. Configure nestedTypeEncodingStrategy to enable."
241+
),
242+
codingPath: codingPath + [key],
243+
)
244+
)
243245

244246
case .flatten(let separator):
245247
let nestedPrefix = prefixedKey(key) + separator
@@ -253,12 +255,14 @@ nonisolated struct CSVKeyedEncodingContainer<Key: CodingKey>: KeyedEncodingConta
253255

254256
case .codable,
255257
.json:
256-
return KeyedEncodingContainer(CSVPoisonKeyedEncodingContainer<NestedKey>(
257-
error: CSVEncodingError.unsupportedType(
258-
"JSON/Codable nested encoding requires using encode(_:forKey:) with the nested value directly"
259-
),
260-
codingPath: codingPath + [key],
261-
))
258+
return KeyedEncodingContainer(
259+
CSVPoisonKeyedEncodingContainer<NestedKey>(
260+
error: CSVEncodingError.unsupportedType(
261+
"JSON/Codable nested encoding requires using encode(_:forKey:) with the nested value directly"
262+
),
263+
codingPath: codingPath + [key],
264+
)
265+
)
262266
}
263267
}
264268

@@ -299,12 +303,16 @@ nonisolated struct CSVKeyedEncodingContainer<Key: CodingKey>: KeyedEncodingConta
299303
}
300304

301305
mutating func encodeIfPresent(_ value: Double?, forKey key: Key) throws {
302-
let formatted = try value.map { try CSVValueFormatter.formatNumber($0, strategy: configuration.numberEncodingStrategy) }
306+
let formatted = try value.map {
307+
try CSVValueFormatter.formatNumber($0, strategy: configuration.numberEncodingStrategy)
308+
}
303309
storage.setValue(formatted ?? "", forKey: prefixedKey(key))
304310
}
305311

306312
mutating func encodeIfPresent(_ value: Float?, forKey key: Key) throws {
307-
let formatted = try value.map { try CSVValueFormatter.formatNumber(Double($0), strategy: configuration.numberEncodingStrategy) }
313+
let formatted = try value.map {
314+
try CSVValueFormatter.formatNumber(Double($0), strategy: configuration.numberEncodingStrategy)
315+
}
308316
storage.setValue(formatted ?? "", forKey: prefixedKey(key))
309317
}
310318

Sources/CSVCoder/Encoder/CSVSingleValueEncoder.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,12 @@ nonisolated struct CSVThrowingKeyedEncodingContainer<Key: CodingKey>: KeyedEncod
155155
keyedBy _: NestedKey.Type,
156156
forKey _: Key
157157
) -> KeyedEncodingContainer<NestedKey> {
158-
KeyedEncodingContainer(CSVPoisonKeyedEncodingContainer<NestedKey>(
159-
error: CSVEncodingError.unsupportedType("Nested containers are not supported"),
160-
codingPath: codingPath,
161-
))
158+
KeyedEncodingContainer(
159+
CSVPoisonKeyedEncodingContainer<NestedKey>(
160+
error: CSVEncodingError.unsupportedType("Nested containers are not supported"),
161+
codingPath: codingPath,
162+
)
163+
)
162164
}
163165

164166
mutating func nestedUnkeyedContainer(forKey key: Key) -> UnkeyedEncodingContainer {
@@ -205,7 +207,8 @@ nonisolated struct CSVSingleValueEncodingContainer: SingleValueEncodingContainer
205207
}
206208

207209
mutating func encode(_ value: Bool) throws {
208-
storage.setValue(CSVValueFormatter.formatBool(value, strategy: configuration.boolEncodingStrategy), forKey: currentKey)
210+
let formatted = CSVValueFormatter.formatBool(value, strategy: configuration.boolEncodingStrategy)
211+
storage.setValue(formatted, forKey: currentKey)
209212
}
210213

211214
mutating func encode(_ value: String) throws {

Tests/CSVCoderTests/CSVConcurrencyStressTests.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ struct CSVConcurrencyStressTests {
5151
#expect(results.count == taskCount)
5252

5353
for csv in results {
54-
let lines = csv
55-
.components(separatedBy: "\n")
54+
let lines = csv.components(separatedBy: "\n")
5655
.filter { !$0.isEmpty }
5756

5857
// First line must be the header.

0 commit comments

Comments
 (0)