Skip to content

Commit b143dc2

Browse files
committed
fix linting
1 parent 86ff2cc commit b143dc2

File tree

4 files changed

+9
-15
lines changed

4 files changed

+9
-15
lines changed

Sources/PayPalMessages/Utils/Log.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func log(_ level: LogLevel, _ message: String, with data: Data? = nil, for envir
2121
options: .prettyPrinted
2222
) else { return }
2323
message += "\n"
24-
message += String(decoding: jsonData, as: UTF8.self)
24+
message += String(data: jsonData, encoding: .utf8) ?? ""
2525
}
2626

2727
print(message)

Tests/PayPalMessagesTests/PayPalMessageLoggerTests.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,8 @@ final class PayPalMessageLoggerTests: XCTestCase {
542542
withJSONObject: expected,
543543
options: .prettyPrinted
544544
) {
545-
let payloadString = String(decoding: payloadData, as: UTF8.self)
546-
let expectedString = String(decoding: expectedData, as: UTF8.self)
545+
let payloadString = String(data: payloadData, encoding: .utf8) ?? ""
546+
let expectedString = String(data: expectedData, encoding: .utf8) ?? ""
547547

548548
print("Expected:\n\(expectedString)\n\nReceived:\n\(payloadString)")
549549
}

Tests/PayPalMessagesTests/PayPalMessageResponseTests.swift

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import XCTest
55
final class MessageResponseTests: XCTestCase {
66

77
func testDecodeMessageResponse() throws {
8-
let json = """
8+
let json = Data("""
99
{
1010
"meta": {
1111
"credit_product_group": "PAY_LATER",
@@ -53,9 +53,7 @@ final class MessageResponseTests: XCTestCase {
5353
}
5454
}
5555
}
56-
"""
57-
// swiftlint:disable force_unwrapping
58-
.data(using: .utf8)!
56+
""".utf8)
5957

6058
let decoder = JSONDecoder()
6159
let messageResponse = try decoder.decode(MessageResponse.self, from: json)

Tests/PayPalMessagesTests/ResponseErrorTests.swift

+4-8
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@ final class ResponseErrorTests: XCTestCase {
1313
}
1414

1515
func testErrorWithoutDetails() throws {
16-
let json = """
16+
let json = Data("""
1717
{
1818
"name": "UNPROCESSABLE_ENTITY",
1919
"message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
2020
"debug_id": "12345"
2121
}
22-
"""
23-
// swiftlint:disable force_unwrapping
24-
.data(using: .utf8)!
22+
""".utf8)
2523

2624
let decoder = JSONDecoder()
2725
let responseError = try decoder.decode(ResponseError.self, from: json)
@@ -32,7 +30,7 @@ final class ResponseErrorTests: XCTestCase {
3230
}
3331

3432
func testErrorWithDetails() throws {
35-
let json = """
33+
let json = Data("""
3634
{
3735
"name": "UNPROCESSABLE_ENTITY",
3836
"message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
@@ -44,9 +42,7 @@ final class ResponseErrorTests: XCTestCase {
4442
}
4543
]
4644
}
47-
"""
48-
// swiftlint:disable force_unwrapping
49-
.data(using: .utf8)!
45+
""".utf8)
5046

5147
let decoder = JSONDecoder()
5248
let responseError = try decoder.decode(ResponseError.self, from: json)

0 commit comments

Comments
 (0)