Skip to content

Commit 11453ca

Browse files
authored
Replace swift format with swift-format (#626)
* swift-format * Update CONTRIBUTING.md
1 parent 96e58b6 commit 11453ca

File tree

97 files changed

+2103
-1350
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+2103
-1350
lines changed

.github/workflows/validate.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,12 @@ on:
55

66
jobs:
77
validate:
8-
runs-on: macOS-latest
8+
runs-on: ubuntu-latest
99
timeout-minutes: 15
1010
steps:
1111
- name: Checkout
1212
uses: actions/checkout@v4
1313
with:
1414
fetch-depth: 1
15-
- name: Install Dependencies
16-
run: |
17-
brew install mint
18-
mint install nicklockwood/swiftformat@0.53.10 --no-link
1915
- name: run script
2016
run: ./scripts/validate.sh

.swift-format

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"version" : 1,
3+
"indentation" : {
4+
"spaces" : 4
5+
},
6+
"tabWidth" : 4,
7+
"fileScopedDeclarationPrivacy" : {
8+
"accessLevel" : "private"
9+
},
10+
"spacesAroundRangeFormationOperators" : false,
11+
"indentConditionalCompilationBlocks" : false,
12+
"indentSwitchCaseLabels" : false,
13+
"lineBreakAroundMultilineExpressionChainComponents" : false,
14+
"lineBreakBeforeControlFlowKeywords" : false,
15+
"lineBreakBeforeEachArgument" : true,
16+
"lineBreakBeforeEachGenericRequirement" : true,
17+
"lineLength" : 150,
18+
"maximumBlankLines" : 1,
19+
"respectsExistingLineBreaks" : true,
20+
"prioritizeKeepingFunctionOutputTogether" : true,
21+
"multiElementCollectionTrailingCommas" : true,
22+
"rules" : {
23+
"AllPublicDeclarationsHaveDocumentation" : false,
24+
"AlwaysUseLiteralForEmptyCollectionInit" : false,
25+
"AlwaysUseLowerCamelCase" : false,
26+
"AmbiguousTrailingClosureOverload" : true,
27+
"BeginDocumentationCommentWithOneLineSummary" : false,
28+
"DoNotUseSemicolons" : true,
29+
"DontRepeatTypeInStaticProperties" : true,
30+
"FileScopedDeclarationPrivacy" : true,
31+
"FullyIndirectEnum" : true,
32+
"GroupNumericLiterals" : true,
33+
"IdentifiersMustBeASCII" : true,
34+
"NeverForceUnwrap" : false,
35+
"NeverUseForceTry" : false,
36+
"NeverUseImplicitlyUnwrappedOptionals" : false,
37+
"NoAccessLevelOnExtensionDeclaration" : true,
38+
"NoAssignmentInExpressions" : true,
39+
"NoBlockComments" : true,
40+
"NoCasesWithOnlyFallthrough" : true,
41+
"NoEmptyTrailingClosureParentheses" : true,
42+
"NoLabelsInCasePatterns" : true,
43+
"NoLeadingUnderscores" : false,
44+
"NoParensAroundConditions" : true,
45+
"NoVoidReturnOnFunctionSignature" : true,
46+
"OmitExplicitReturns" : true,
47+
"OneCasePerLine" : true,
48+
"OneVariableDeclarationPerLine" : true,
49+
"OnlyOneTrailingClosureArgument" : true,
50+
"OrderedImports" : true,
51+
"ReplaceForEachWithForLoop" : true,
52+
"ReturnVoidInsteadOfEmptyTuple" : true,
53+
"UseEarlyExits" : false,
54+
"UseExplicitNilCheckInConditions" : false,
55+
"UseLetInEveryBoundCaseVariable" : false,
56+
"UseShorthandTypeNames" : true,
57+
"UseSingleLinePropertyGetter" : false,
58+
"UseSynthesizedInitializer" : false,
59+
"UseTripleSlashForDocumentationComments" : true,
60+
"UseWhereClausesInForLoops" : false,
61+
"ValidateDocumentationComments" : false
62+
}
63+
}

.swiftformat

Lines changed: 0 additions & 23 deletions
This file was deleted.

Benchmark/Package.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ let package = Package(
1010
.package(name: "Benchmark", url: "https://github.com/google/swift-benchmark", from: "0.1.0"),
1111
],
1212
targets: [
13-
.target(name: "soto-benchmark", dependencies: [
14-
.product(name: "SotoCore", package: "soto-core"),
15-
.product(name: "Benchmark", package: "Benchmark"),
16-
]),
13+
.target(
14+
name: "soto-benchmark",
15+
dependencies: [
16+
.product(name: "SotoCore", package: "soto-core"),
17+
.product(name: "Benchmark", package: "Benchmark"),
18+
]
19+
)
1720
]
1821
)

Benchmark/Sources/soto-benchmark/AWSClientSuite.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,25 @@ let awsClientSuite = BenchmarkSuite(name: "AWSClient", settings: Iterations(1000
6565
middlewares: [RequestThrowMiddleware()]
6666
)
6767
let jsonService = AWSServiceConfig(
68-
region: .useast1, partition: .aws, service: "test-service", serviceProtocol: .json(version: "1.1"), apiVersion: "10-10-2010"
68+
region: .useast1,
69+
partition: .aws,
70+
service: "test-service",
71+
serviceProtocol: .json(version: "1.1"),
72+
apiVersion: "10-10-2010"
6973
)
7074
let xmlService = AWSServiceConfig(
71-
region: .useast1, partition: .aws, service: "test-service", serviceProtocol: .restxml, apiVersion: "10-10-2010"
75+
region: .useast1,
76+
partition: .aws,
77+
service: "test-service",
78+
serviceProtocol: .restxml,
79+
apiVersion: "10-10-2010"
7280
)
7381
let queryService = AWSServiceConfig(
74-
region: .useast1, partition: .aws, service: "test-service", serviceProtocol: .query, apiVersion: "10-10-2010"
82+
region: .useast1,
83+
partition: .aws,
84+
service: "test-service",
85+
serviceProtocol: .query,
86+
apiVersion: "10-10-2010"
7587
)
7688

7789
suite.benchmark("empty-request") {

Benchmark/Sources/soto-benchmark/AWSSignerV4Suite.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,20 @@ let awsSignerV4Suite = BenchmarkSuite(name: "AWSSignerV4", settings: Iterations(
2222
let signer = AWSSigner(credentials: credentials, name: "s3", region: "eu-west-1")
2323

2424
suite.benchmark("sign-headers") {
25-
_ = signer.signHeaders(url: URL(string: "https://test-bucket.s3.amazonaws.com/test-put.txt")!, method: .GET, headers: ["Content-Type": "application/x-www-form-urlencoded; charset=utf-8"], body: .string(string))
25+
_ = signer.signHeaders(
26+
url: URL(string: "https://test-bucket.s3.amazonaws.com/test-put.txt")!,
27+
method: .GET,
28+
headers: ["Content-Type": "application/x-www-form-urlencoded; charset=utf-8"],
29+
body: .string(string)
30+
)
2631
}
2732

2833
suite.benchmark("sign-url") {
29-
_ = signer.signURL(url: URL(string: "https://test-bucket.s3.amazonaws.com/test-put.txt")!, method: .GET, body: .string(string), expires: .hours(1))
34+
_ = signer.signURL(
35+
url: URL(string: "https://test-bucket.s3.amazonaws.com/test-put.txt")!,
36+
method: .GET,
37+
body: .string(string),
38+
expires: .hours(1)
39+
)
3040
}
3141
}

Benchmark/Sources/soto-benchmark/EncoderSuites.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import Benchmark
1616
import Foundation
1717
import SotoCore
18+
1819
#if compiler(>=5.10)
1920
internal import SotoXML
2021
#else

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ The main development branch of the repository is `main`. Each major version rel
2828

2929
### Formatting
3030

31-
We use Nick Lockwood's SwiftFormat for formatting code. PRs will not be accepted if they haven't be formatted. The current version of SwiftFormat we are using is v0.53.10.
31+
We use Apple's swift-format for formatting code. PRs will not be accepted if they haven't be formatted.
3232

3333
All new files need to include the following file header at the top
3434
```swift
3535
//===----------------------------------------------------------------------===//
3636
//
3737
// This source file is part of the Soto for AWS open source project
3838
//
39-
// Copyright (c) 2017-2020 the Soto project authors
39+
// Copyright (c) 2017-2024 the Soto project authors
4040
// Licensed under Apache License v2.0
4141
//
4242
// See LICENSE.txt for license information

Package.swift

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,23 @@ let package = Package(
7676
],
7777
swiftSettings: swiftSettings
7878
),
79-
.target(name: "SotoTestUtils", dependencies: [
80-
.byName(name: "SotoCore"),
81-
.byName(name: "SotoXML"),
82-
.product(name: "Logging", package: "swift-log"),
83-
.product(name: "NIO", package: "swift-nio"),
84-
.product(name: "NIOFoundationCompat", package: "swift-nio"),
85-
.product(name: "NIOHTTP1", package: "swift-nio"),
86-
.product(name: "NIOPosix", package: "swift-nio"),
87-
.product(name: "NIOTestUtils", package: "swift-nio"),
88-
]),
79+
.target(
80+
name: "SotoTestUtils",
81+
dependencies: [
82+
.byName(name: "SotoCore"),
83+
.byName(name: "SotoXML"),
84+
.product(name: "Logging", package: "swift-log"),
85+
.product(name: "NIO", package: "swift-nio"),
86+
.product(name: "NIOFoundationCompat", package: "swift-nio"),
87+
.product(name: "NIOHTTP1", package: "swift-nio"),
88+
.product(name: "NIOPosix", package: "swift-nio"),
89+
.product(name: "NIOTestUtils", package: "swift-nio"),
90+
]
91+
),
8992
.target(
9093
name: "SotoXML",
9194
dependencies: [
92-
.byName(name: "CSotoExpat"),
95+
.byName(name: "CSotoExpat")
9396
],
9497
swiftSettings: swiftSettings
9598
),
@@ -107,16 +110,25 @@ let package = Package(
107110
.product(name: "NIOPosix", package: "swift-nio"),
108111
]
109112
),
110-
.testTarget(name: "SotoSignerV4Tests", dependencies: [
111-
.byName(name: "SotoSignerV4"),
112-
]),
113-
.testTarget(name: "SotoXMLTests", dependencies: [
114-
.byName(name: "SotoXML"),
115-
.byName(name: "SotoCore"),
116-
]),
117-
.testTarget(name: "INIParserTests", dependencies: [
118-
.byName(name: "INIParser"),
119-
]),
113+
.testTarget(
114+
name: "SotoSignerV4Tests",
115+
dependencies: [
116+
.byName(name: "SotoSignerV4")
117+
]
118+
),
119+
.testTarget(
120+
name: "SotoXMLTests",
121+
dependencies: [
122+
.byName(name: "SotoXML"),
123+
.byName(name: "SotoCore"),
124+
]
125+
),
126+
.testTarget(
127+
name: "INIParserTests",
128+
dependencies: [
129+
.byName(name: "INIParser")
130+
]
131+
),
120132
],
121133
swiftLanguageVersions: [.v5, .version("6")]
122134
)

Sources/INIParser/INIParser.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public final class INIParser {
2222
internal var _sections: [String: [String: String]] = [:]
2323
internal var _anonymousSection: [String: String] = [:]
2424

25-
public var sections: [String: [String: String]] { return self._sections }
26-
public var anonymousSection: [String: String] { return self._anonymousSection }
25+
public var sections: [String: [String: String]] { self._sections }
26+
public var anonymousSection: [String: String] { self._anonymousSection }
2727

2828
public enum Error: Swift.Error {
2929
case invalidSyntax

Sources/SotoCore/AWSClient+Paginate.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ extension AWSClient {
7171
if let input {
7272
let output = try await self.sequence.command(input, self.sequence.logger)
7373
if let token = output[keyPath: sequence.outputKey],
74-
sequence.inputKey == nil || token != input[keyPath: sequence.inputKey!],
75-
sequence.moreResultsKey == nil || output[keyPath: sequence.moreResultsKey!] == true
74+
sequence.inputKey == nil || token != input[keyPath: sequence.inputKey!],
75+
sequence.moreResultsKey == nil || output[keyPath: sequence.moreResultsKey!] == true
7676
{
7777
self.input = input.usingPaginationToken(token)
7878
} else {
@@ -86,7 +86,7 @@ extension AWSClient {
8686

8787
/// Make async iterator
8888
public func makeAsyncIterator() -> AsyncIterator {
89-
return AsyncIterator(sequence: self)
89+
AsyncIterator(sequence: self)
9090
}
9191
}
9292
}

0 commit comments

Comments
 (0)