Skip to content

Commit 33e03c9

Browse files
committed
Update formatting
1 parent a997ffa commit 33e03c9

22 files changed

+171
-270
lines changed

.swiftlint.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
included:
2+
- Sources
3+
- Tests
4+
5+
disabled_rules:
6+
- identifier_name
7+
- todo

Sources/Libraries/Atomic/Atomic.swift

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public final class Atomic<Value> {
3333
_value = value
3434
}
3535

36-
3736
/// Atomically replaces the contents of the variable.
3837
///
3938
/// Returns the old value.

Sources/SwiftJSONRPC/Client/RPCClient.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ open class RPCClient {
1212

1313
// MARK: - Properties
1414

15-
public var requestRetrier: RequestRetrier? = nil
15+
public var requestRetrier: RequestRetrier?
1616

1717
public var coder = Coder()
1818

Sources/SwiftJSONRPC/Client/Retrier/RequestRetrier.swift

+3-5
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66
//
77
// ----------------------------------------------------------------------------
88

9-
public protocol RequestRetrier
10-
{
11-
// MARK: - Functions
9+
public protocol RequestRetrier {
10+
11+
// MARK: - Functions
1212

1313
func should(client: RPCClient, retryRequest request: Request, afterResponse response: Response) -> Bool
1414

1515
}
16-
17-
// ----------------------------------------------------------------------------

Sources/SwiftJSONRPC/Coder/Coder.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public struct Coder {
4040

4141
func decode<Result: InvocationResult>(_ type: Result.Type, from result: Response.Result) throws -> Result {
4242
guard Result.self != VoidInvocationResult.self else {
43-
return VoidInvocationResult() as! Result
43+
return VoidInvocationResult() as! Result // swiftlint:disable:this force_cast
4444
}
4545
do {
4646
let data = try JSONSerialization.data(withJSONObject: result, options: .fragmentsAllowed)

Sources/SwiftJSONRPC/Error/InvocationError.swift

+1-5
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@
66
//
77
// ----------------------------------------------------------------------------
88

9-
public enum InvocationError: Error
10-
{
9+
public enum InvocationError: Error {
1110
case applicationError(cause: Error)
1211
case rpcError(error: RPCError)
1312
case canceled
1413
}
15-
16-
// ----------------------------------------------------------------------------
17-

Sources/SwiftJSONRPC/Error/RPCError.swift

+13-21
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,28 @@
66
//
77
// ----------------------------------------------------------------------------
88

9-
public struct RPCError: Error
10-
{
11-
// MARK: - Construction
9+
public struct RPCError: Error {
1210

13-
init(code: Int, message: String, data: Any?)
14-
{
15-
// Init instance variables
16-
self.code = code
17-
self.message = message
18-
self.data = data
19-
}
11+
// MARK: - Properties
2012

21-
// MARK: - Properties
13+
public let code: Int
2214

23-
public let code: Int
15+
public let message: String
2416

25-
public let message: String
17+
public let data: Any?
2618

27-
public let data: Any?
19+
// MARK: - Initialization
2820

21+
init(code: Int, message: String, data: Any?) {
22+
self.code = code
23+
self.message = message
24+
self.data = data
25+
}
2926
}
3027

31-
// ----------------------------------------------------------------------------
28+
extension RPCError {
3229

33-
extension RPCError
34-
{
35-
// MARK: - Constants
30+
// MARK: - Constants
3631

3732
/// Invalid JSON was received by the server.
3833
/// An error occurred on the server while parsing the JSON text.
@@ -51,6 +46,3 @@ extension RPCError
5146
public static let internalError = RPCError(code: -32603, message: "Internal error", data: nil)
5247

5348
}
54-
55-
// ----------------------------------------------------------------------------
56-

Sources/SwiftJSONRPC/RequestExecutor/HTTP/Adapter/DefaultHTTPRequestAdapter.swift

+4-7
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,15 @@
66
//
77
// ----------------------------------------------------------------------------
88

9-
open class DefaultHTTPRequestAdapter: HTTPRequestAdapter
10-
{
11-
// MARK: - Construction
9+
open class DefaultHTTPRequestAdapter: HTTPRequestAdapter {
10+
11+
// MARK: - Initialization
1212

1313
public init() { }
1414

15-
// MARK: - Functions
15+
// MARK: - Functions
1616

1717
open func adapt(request: HTTPRequest) -> HTTPRequest {
1818
return request
1919
}
20-
2120
}
22-
23-
// ----------------------------------------------------------------------------

Sources/SwiftJSONRPC/RequestExecutor/HTTP/Adapter/DefaultHTTPResponseAdapter.swift

+5-9
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,19 @@
66
//
77
// ----------------------------------------------------------------------------
88

9-
open class DefaultHTTPResponseAdapter: HTTPResponseAdapter
10-
{
11-
// MARK: - Construction
9+
open class DefaultHTTPResponseAdapter: HTTPResponseAdapter {
10+
11+
// MARK: - Initialization
1212

1313
public init() { }
1414

15-
// MARK: - Functions
15+
// MARK: - Functions
1616

17-
open func adapt(response: HTTPResponse, forRequest request: HTTPRequest) throws -> HTTPResponse
18-
{
17+
open func adapt(response: HTTPResponse, forRequest request: HTTPRequest) throws -> HTTPResponse {
1918
guard (200..<300).contains(response.code) else {
2019
throw HTTPResponseStatusCodeError(cause: nil)
2120
}
2221

2322
return response
2423
}
25-
2624
}
27-
28-
// ----------------------------------------------------------------------------

Sources/SwiftJSONRPC/RequestExecutor/HTTP/Adapter/HTTPRequestAdapter.swift

+3-5
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66
//
77
// ----------------------------------------------------------------------------
88

9-
public protocol HTTPRequestAdapter
10-
{
11-
// MARK: - Functions
9+
public protocol HTTPRequestAdapter {
10+
11+
// MARK: - Functions
1212

1313
func adapt(request: HTTPRequest) throws -> HTTPRequest
1414

1515
}
16-
17-
// ----------------------------------------------------------------------------

Sources/SwiftJSONRPC/RequestExecutor/HTTP/Adapter/HTTPResponseAdapter.swift

+3-5
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66
//
77
// ----------------------------------------------------------------------------
88

9-
public protocol HTTPResponseAdapter
10-
{
11-
// MARK: - Functions
9+
public protocol HTTPResponseAdapter {
10+
11+
// MARK: - Functions
1212

1313
func adapt(response: HTTPResponse, forRequest request: HTTPRequest) throws -> HTTPResponse
1414

1515
}
16-
17-
// ----------------------------------------------------------------------------

Sources/SwiftJSONRPC/RequestExecutor/HTTP/Client/HTTPRequest.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ extension HTTPRequest: Equatable {
2626

2727
// MARK: - Functions
2828

29-
public static func ==(lhs: HTTPRequest, rhs: HTTPRequest) -> Bool {
29+
public static func == (lhs: HTTPRequest, rhs: HTTPRequest) -> Bool {
3030
return lhs.method == rhs.method &&
3131
lhs.url == rhs.url &&
3232
lhs.headers == rhs.headers &&

Sources/SwiftJSONRPC/RequestExecutor/HTTP/Client/HTTPResponse.swift

+2-6
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@
88

99
import Foundation
1010

11-
// ----------------------------------------------------------------------------
11+
public struct HTTPResponse {
1212

13-
public struct HTTPResponse
14-
{
15-
// MARK: - Properties
13+
// MARK: - Properties
1614

1715
public var url: URL
1816

@@ -23,5 +21,3 @@ public struct HTTPResponse
2321
public var body: Data
2422

2523
}
26-
27-
// ----------------------------------------------------------------------------

Sources/SwiftJSONRPC/RequestExecutor/HTTP/Client/URLSessionHTTPClient.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ struct URLSessionHTTPClient: HTTPClient {
6565

6666
}
6767

68-
extension HTTPRequest {
68+
extension HTTPRequest {
6969

7070
// MARK: - Functions
7171

0 commit comments

Comments
 (0)