Skip to content

Commit ecf2743

Browse files
authored
tech(swiftlint): Use SwiftLint to lint code (#19)
1 parent 58b328a commit ecf2743

35 files changed

+169
-210
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,8 @@ jobs:
1616
- name: Checkout repo
1717
uses: actions/checkout@v2
1818

19+
- name: Lint code
20+
uses: swiftlint lint
21+
1922
- name: Run tests
2023
run: swift test --enable-test-discovery

.swift-format

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

.swiftlint.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
included:
2+
- Sources
3+
- Tests
4+
5+
excluded:
6+
- build
7+
- .build
8+
9+
disabled_rules:
10+
- statement_position
11+
- type_name
12+
13+
opt_in_rules:
14+
- closure_end_indentation
15+
- conditional_returns_on_newline
16+
- empty_count
17+
- indentation_width
18+
19+
line_length: 120
20+
warning_threshold: 0

Package.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ let package = Package(
1111
.library(name: "SimpleHTTP", targets: ["SimpleHTTP"])
1212
],
1313
dependencies: [
14-
// Dependencies declare other packages that this package depends on.
15-
// .package(url: /* package url */, from: "1.0.0"),
16-
.package(url: "https://github.com/apple/swift-format", branch: "main")
1714
],
1815
targets: [
1916
.target(name: "SimpleHTTPFoundation", dependencies: []),

Sources/SimpleHTTP/Interceptor/CompositeInterceptor.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,39 @@ import Combine
44
/// Use an Array of `Interceptor` as a single `Interceptor`
55
public struct CompositeInterceptor: ExpressibleByArrayLiteral, Sequence {
66
let interceptors: [Interceptor]
7-
7+
88
public init(arrayLiteral interceptors: Interceptor...) {
99
self.interceptors = interceptors
1010
}
11-
11+
1212
public func makeIterator() -> Array<Interceptor>.Iterator {
1313
interceptors.makeIterator()
1414
}
1515
}
16-
16+
1717
extension CompositeInterceptor: Interceptor {
1818
public func adaptRequest<Output>(_ request: Request<Output>) -> Request<Output> {
1919
reduce(request) { request, interceptor in
2020
interceptor.adaptRequest(request)
2121
}
2222
}
23-
23+
2424
public func rescueRequest<Output>(_ request: Request<Output>, error: Error) -> AnyPublisher<Void, Error>? {
2525
let publishers = compactMap { $0.rescueRequest(request, error: error) }
26-
26+
2727
guard !publishers.isEmpty else {
2828
return nil
2929
}
30-
30+
3131
return Publishers.MergeMany(publishers).eraseToAnyPublisher()
3232
}
33-
33+
3434
public func adaptOutput<Output>(_ response: Output, for request: Request<Output>) throws -> Output {
3535
try reduce(response) { response, interceptor in
3636
try interceptor.adaptOutput(response, for: request)
3737
}
3838
}
39-
39+
4040
public func receivedResponse<Output>(_ result: Result<Output, Error>, for request: Request<Output>) {
4141
forEach { interceptor in
4242
interceptor.receivedResponse(result, for: request)

Sources/SimpleHTTP/Interceptor/Interceptor.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public typealias Interceptor = RequestInterceptor & ResponseInterceptor
77
public protocol RequestInterceptor {
88
/// Should be called before making the request to provide modifications to `request`
99
func adaptRequest<Output>(_ request: Request<Output>) -> Request<Output>
10-
10+
1111
/// catch and retry a failed request
1212
/// - Returns: nil if the request should not be retried. Otherwise a publisher that will be executed before
1313
/// retrying the request
@@ -20,7 +20,7 @@ public protocol ResponseInterceptor {
2020
/// optionally throwing an error instead if needed
2121
/// - Parameter request: the request that was sent to the server
2222
func adaptOutput<Output>(_ output: Output, for request: Request<Output>) throws -> Output
23-
23+
2424
/// Notify of received response for `request`
2525
/// - Parameter request: the request that was sent to the server
2626
func receivedResponse<Output>(_ result: Result<Output, Error>, for request: Request<Output>)
@@ -30,11 +30,11 @@ extension RequestInterceptor {
3030
func shouldRescueRequest<Output>(_ request: Request<Output>, error: Error) async throws -> Bool {
3131
var cancellable: Set<AnyCancellable> = []
3232
let onCancel = { cancellable.removeAll() }
33-
33+
3434
guard let rescuePublisher = rescueRequest(request, error: error) else {
3535
return false
3636
}
37-
37+
3838
return try await withTaskCancellationHandler(
3939
handler: { onCancel() },
4040
operation: {

Sources/SimpleHTTP/MultipartForm/MultipartFormData.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public struct MultipartFormData {
152152
let headers = defineBodyPartHeader(name: name, fileName: fileName, mimeType: mimeType)
153153
let stream = InputStream(data: data)
154154
let length = data.count
155-
155+
156156
bodyParts.append(BodyPart(headers: headers, stream: stream, length: length))
157157
}
158158

Sources/SimpleHTTP/Query/Dictionary+QueryParam.swift

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

33
extension Dictionary where Key == String, Value == QueryParam {
44
/// transform query params into URLQueryItem`
5-
var queryItems: [URLQueryItem] {
5+
var queryItems: [URLQueryItem] {
66
self.flatMap { key, value -> [URLQueryItem] in
77
switch value.queryValue {
88
case .single(let value):
@@ -14,5 +14,5 @@ extension Dictionary where Key == String, Value == QueryParam {
1414
}
1515
}
1616
}
17-
17+
1818
}

Sources/SimpleHTTP/Query/QueryParam.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ extension Array: QueryParam where Element: QueryParam {
5050
return values
5151
}
5252
}
53-
53+
5454
return .collection(values)
5555
}
5656
}

Sources/SimpleHTTP/Request/Path.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,12 @@ public struct Path: Equatable, ExpressibleByStringLiteral, ExpressibleByStringIn
3232
public init(stringLiteral value: StringLiteralType) {
3333
self.init(value: value)
3434
}
35-
35+
3636
public init(stringInterpolation: DefaultStringInterpolation) {
3737
self.init(value: stringInterpolation.description)
3838
}
39-
39+
4040
public static func ==(lhs: Path, rhs: String) -> Bool {
4141
lhs.value == rhs
4242
}
4343
}
44-

0 commit comments

Comments
 (0)