Skip to content

Commit 63e7b29

Browse files
authored
fix: Fixes issue where linter wasn’t using config file on CI (#458)
* Fixes issue where linter wasn’t using config file on CI * Exclude Tests dir * Attempt to fix file exclusions * Force all file exclusion path variations * Updates swiftlint github action version
1 parent 9e8640b commit 63e7b29

File tree

11 files changed

+41
-39
lines changed

11 files changed

+41
-39
lines changed

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ jobs:
2525
- name: Checkout sources
2626
uses: actions/checkout@v2
2727
- name: Swift Lint ClientRuntime
28-
uses: norio-nomura/action-swiftlint@3.1.0
28+
uses: norio-nomura/action-swiftlint@3.2.1
2929
with:
30-
args: --path ./Packages
30+
args: --path ./Packages --config ./Packages/.swiftlint.yml

Packages/.swiftlint.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
excluded:
2-
- SmithyTestUtil/Tests
3-
- ClientRuntime/Tests
2+
- ./SmithyTestUtil/*
3+
- ./ClientRuntime/Tests/*
4+
- ./Packages/SmithyTestUtil/*
5+
- ./Packages/ClientRuntime/Tests/*
46
- .build
57

68
analyzer_rules:
@@ -18,6 +20,7 @@ disabled_rules:
1820
- file_length
1921
- syntactic_sugar
2022
- unused_capture_list
23+
- type_body_length
2124

2225
opt_in_rules:
2326
- empty_count
@@ -41,6 +44,7 @@ identifier_name:
4144
line_length:
4245
warning: 120
4346
error: 160
47+
ignores_comments: true
4448
opening_brace: error
4549
return_arrow_whitespace: error
4650
statement_position:

Packages/ClientRuntime/Sources/Middleware/OperationStack.swift

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,29 @@ public struct OperationStack<OperationStackInput,
4141

4242
let result = try await initialize.handle(context: context, input: input)
4343
guard let output = result.output else {
44-
throw ClientError.unknownError("Something went terribly wrong where the output was not set on the response. Please open a ticket with us at https://github.com/awslabs/aws-sdk-swift")
44+
let errorMessage = [
45+
"Something went terribly wrong where the output was not set on the response.",
46+
"Please open a ticket with us at https://github.com/awslabs/aws-sdk-swift"
47+
].joined(separator: " ")
48+
throw ClientError.unknownError(errorMessage)
4549
}
4650
return output
4751
}
4852

49-
mutating public func presignedRequest<H: Handler>(context: HttpContext,
50-
input: OperationStackInput,
51-
next: H) async throws -> SdkHttpRequestBuilder?
52-
where H.Input == SdkHttpRequest,
53-
H.Output == OperationOutput<OperationStackOutput>,
54-
H.Context == HttpContext {
53+
mutating public func presignedRequest<H: Handler>(
54+
context: HttpContext,
55+
input: OperationStackInput,
56+
next: H
57+
) async throws -> SdkHttpRequestBuilder? where
58+
H.Input == SdkHttpRequest,
59+
H.Output == OperationOutput<OperationStackOutput>,
60+
H.Context == HttpContext {
5561
var builder: SdkHttpRequestBuilder?
56-
self.finalizeStep.intercept(position: .after,
57-
middleware: PresignerShim<OperationStackOutput, OperationStackError>(handler: { buildInMiddleware in
58-
builder = buildInMiddleware
59-
}))
62+
self.finalizeStep.intercept(
63+
position: .after,
64+
middleware: PresignerShim<OperationStackOutput, OperationStackError>(handler: { buildInMiddleware in
65+
builder = buildInMiddleware
66+
}))
6067
_ = try await handleMiddleware(context: context, input: input, next: next)
6168
return builder
6269
}

Packages/ClientRuntime/Sources/Middleware/PresignerShimHandler.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ struct PresignerShim<OperationStackOutput: HttpResponseBinding,
3535
let output: OperationStackOutput? = try OperationStackOutput(httpResponse: httpResponse, decoder: nil)
3636
return .init(httpResponse: httpResponse, output: output)
3737
} catch {
38-
throw SdkError<OperationStackError>.unknown(ClientError.unknownError("PresignerShimHandler: This code should not execute"))
38+
throw SdkError<OperationStackError>.unknown(
39+
ClientError.unknownError("PresignerShimHandler: This code should not execute")
40+
)
3941
}
4042
}
4143
}

Packages/ClientRuntime/Sources/Networking/Endpoint.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public struct Endpoint: Hashable {
3333
}
3434

3535
self.init(host: host,
36-
path: url.path,
36+
path: url.path,
3737
port: Int16(url.port ?? 443),
3838
queryItems: url.toQueryItems(),
3939
protocolType: ProtocolType(rawValue: url.scheme ?? ProtocolType.https.rawValue),

Packages/ClientRuntime/Sources/Networking/Http/CRT/CRTClientEngine.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@ import Darwin
1111
#endif
1212

1313
public class CRTClientEngine: HttpClientEngine {
14-
15-
// Swiftlint is treating this `actor` declaration as a function.
16-
// I am not sure but I think it is because Swiftlint is out-of-date
17-
// on our CI. Until CI can be updated, I am disabling the warning
18-
// generated by this actor declaration.
19-
//
20-
// swiftlint:disable:next function_body_length
2114
actor SerialExecutor {
2215
private var logger: LogAgent
2316

@@ -109,7 +102,10 @@ public class CRTClientEngine: HttpClientEngine {
109102
await serialExecutor.closeAllPendingConnections()
110103
}
111104

112-
public func makeHttpRequestStreamOptions(_ request: SdkHttpRequest, _ continuation: StreamContinuation) -> HttpRequestOptions {
105+
public func makeHttpRequestStreamOptions(
106+
_ request: SdkHttpRequest,
107+
_ continuation: StreamContinuation
108+
) -> HttpRequestOptions {
113109
let response = HttpResponse()
114110
let crtRequest = request.toHttpRequest(bufferSize: windowSize)
115111
let streamReader: StreamReader = DataStreamReader()

Packages/ClientRuntime/Sources/Networking/Http/Middlewares/ContentLengthMiddleware.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public struct ContentLengthMiddleware<OperationStackOutput: HttpResponseBinding>
2323
switch stream {
2424
case .buffer(let bytes):
2525
input.headers.update(name: "Content-Length", value: String(bytes.length))
26-
case .reader(_):
26+
case .reader:
2727
input.headers.update(name: "Transfer-Encoded", value: "Chunked")
2828
}
2929
default:

Packages/ClientRuntime/Sources/Networking/Http/Middlewares/MutateHeadersMiddleware.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@ public struct MutateHeadersMiddleware<OperationStackOutput: HttpResponseBinding>
3535
}
3636

3737
if !conditionallySet.dictionary.isEmpty {
38-
for header in conditionallySet.headers {
39-
if !input.headers.exists(name: header.name) {
40-
input.headers.add(name: header.name, values: header.value)
41-
}
38+
for header in conditionallySet.headers where !input.headers.exists(name: header.name) {
39+
input.headers.add(name: header.name, values: header.value)
4240
}
4341
}
4442

Packages/ClientRuntime/Sources/PrimitiveTypeExtensions/String+Extensions.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,7 @@ extension String {
116116

117117
public extension String {
118118
func stripFirstMatching(prefixes: [String]) -> String {
119-
for prefixToStrip in prefixes {
120-
if self.hasPrefix(prefixToStrip) {
121-
return self.removePrefix(prefixToStrip)
122-
}
123-
}
124-
return self
119+
return prefixes.first(where: hasPrefix(_:)).map(removePrefix(_:)) ?? self
125120
}
126121
}
127122

Packages/ClientRuntime/Sources/Retries/ExponentialBackOffJitterMode.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public enum ExponentialBackOffJitterMode {
1616
extension ExponentialBackOffJitterMode {
1717
func toCRTType() -> CRTExponentialBackoffJitterMode {
1818
switch self {
19-
case .default : return .default
19+
case .default: return .default
2020
case .none: return .none
2121
case .full: return .full
2222
case .decorrelated: return .decorrelated

0 commit comments

Comments
 (0)