Skip to content

Commit dd9aca3

Browse files
authored
fix formatting so that sanity script passes (#7)
* fix formatting so that sanity script passes motivation: consistent formatting as prep for OSS changes: run swiftformat to align formatting * dont use TSAN on 18.04
1 parent 0fa022e commit dd9aca3

File tree

7 files changed

+24
-26
lines changed

7 files changed

+24
-26
lines changed

Sources/CodableStructuredHeaders/Decoder/KeyedTopLevelListDecoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct KeyedTopLevelListDecoder<Key: CodingKey, BaseData: RandomAccessCollection
2323
private var list: [ItemOrInnerList]
2424

2525
private var decoder: _StructuredFieldDecoder<BaseData>
26-
26+
2727
init(_ list: [ItemOrInnerList], decoder: _StructuredFieldDecoder<BaseData>) {
2828
self.list = list
2929
self.decoder = decoder

Sources/CodableStructuredHeaders/StructuredHeaderField.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public protocol StructuredHeaderField: Codable {
2121
static var structuredFieldType: StructuredHeaderFieldType { get }
2222
}
2323

24-
2524
/// The kinds of header fields used in HTTP Structured Headers.
2625
public enum StructuredHeaderFieldType {
2726
/// An item field consists of a single item, optionally with parameters.

Sources/StructuredHeaders/FieldParser.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -523,24 +523,24 @@ extension String {
523523
// `StrippingStringEscapesCollection` for more details on what we're doing here.
524524
let unescapedBytes = StrippingStringEscapesCollection(bytes, escapes: escapes)
525525
#if canImport(Darwin)
526-
if #available(macOS 10.16, macCatalyst 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *) {
527-
return String(unsafeUninitializedCapacity: unescapedBytes.count) { innerPtr in
528-
let (_, endIndex) = innerPtr.initialize(from: unescapedBytes)
529-
return endIndex
530-
}
531-
} else {
532-
return String(decoding: unescapedBytes, as: UTF8.self)
526+
if #available(macOS 10.16, macCatalyst 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *) {
527+
return String(unsafeUninitializedCapacity: unescapedBytes.count) { innerPtr in
528+
let (_, endIndex) = innerPtr.initialize(from: unescapedBytes)
529+
return endIndex
533530
}
534-
#else
535-
#if compiler(>=5.3)
536-
return String(unsafeUninitializedCapacity: unescapedBytes.count) { innerPtr in
537-
let (_, endIndex) = innerPtr.initialize(from: unescapedBytes)
538-
return endIndex
539-
}
540-
#else
541-
return String(decoding: unescapedBytes, as: UTF8.self)
542-
#endif
543-
#endif
531+
} else {
532+
return String(decoding: unescapedBytes, as: UTF8.self)
533+
}
534+
#else
535+
#if compiler(>=5.3)
536+
return String(unsafeUninitializedCapacity: unescapedBytes.count) { innerPtr in
537+
let (_, endIndex) = innerPtr.initialize(from: unescapedBytes)
538+
return endIndex
539+
}
540+
#else
541+
return String(decoding: unescapedBytes, as: UTF8.self)
542+
#endif
543+
#endif
544544
}
545545
}
546546

Sources/StructuredHeaders/FieldSerializer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ extension StructuredFieldSerializer {
166166
self.data.append(contentsOf: key.utf8)
167167
}
168168

169-
private mutating func serializeABareItem(_ item: BareItem) throws{
169+
private mutating func serializeABareItem(_ item: BareItem) throws {
170170
switch item {
171171
case .integer(let int):
172172
guard let wideInt = Int64(exactly: int), validIntegerRange.contains(wideInt) else {

Tests/StructuredHeadersTests/StructuredFieldDecoderTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct ListyDictionaryParameterisedList: Codable, Equatable {
3333

3434
struct ItemField<Base: Codable & Equatable>: StructuredHeaderField, Equatable {
3535
static var structuredFieldType: StructuredHeaderFieldType {
36-
return .item
36+
.item
3737
}
3838

3939
var item: Base
@@ -45,7 +45,7 @@ struct ItemField<Base: Codable & Equatable>: StructuredHeaderField, Equatable {
4545

4646
struct List<Base: Codable & Equatable>: StructuredHeaderField, Equatable {
4747
static var structuredFieldType: StructuredHeaderFieldType {
48-
return .list
48+
.list
4949
}
5050

5151
var items: [Base]
@@ -57,7 +57,7 @@ struct List<Base: Codable & Equatable>: StructuredHeaderField, Equatable {
5757

5858
struct DictionaryField<Key: Codable & Hashable, Value: Codable & Equatable>: StructuredHeaderField, Equatable {
5959
static var structuredFieldType: StructuredHeaderFieldType {
60-
return .dictionary
60+
.dictionary
6161
}
6262

6363
var items: [Key: Value]

Tests/StructuredHeadersTests/StructuredFieldEncoderTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ final class StructuredFieldEncoderTests: XCTestCase {
4747
func testEncodeKeyedItemHeader() throws {
4848
struct KeyedItem<ItemType: Codable & Equatable>: Equatable, StructuredHeaderField {
4949
static var structuredFieldType: StructuredHeaderFieldType {
50-
return .item
50+
.item
5151
}
52+
5253
var item: ItemType
5354
var parameters: [String: Bool]
5455
}

docker/docker-compose.1804.53.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ services:
1414

1515
test:
1616
image: swift-http-structured-headers:18.04-5.3
17-
environment:
18-
- SANITIZER_ARG=--sanitize=thread
1917

2018
shell:
2119
image: swift-http-structured-headers:18.04-5.3

0 commit comments

Comments
 (0)