-
Notifications
You must be signed in to change notification settings - Fork 0
fix: resolve SwiftLint violations causing CI lint failure #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3fa7d6c
0bf27a4
b83775c
ed2cb20
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -124,22 +124,26 @@ final class MockURLProtocol: URLProtocol, @unchecked Sendable { | |
| let path = request.url?.absoluteString ?? "" | ||
| for (key, value) in responses { | ||
| if path.contains(key) { | ||
| guard let requestURL = request.url else { continue } | ||
| let response = HTTPURLResponse( | ||
| url: request.url!, | ||
| url: requestURL, | ||
| statusCode: value.0, | ||
| httpVersion: nil, | ||
| headerFields: ["Content-Type": "application/json"] | ||
| )! | ||
| return (response, value.1) | ||
| ) | ||
| if let response { | ||
| return (response, value.1) | ||
| } | ||
| } | ||
| } | ||
| let fallbackURL = request.url ?? URL(string: "https://example.com")! | ||
| let response = HTTPURLResponse( | ||
| url: request.url!, | ||
| url: fallbackURL, | ||
| statusCode: 404, | ||
| httpVersion: nil, | ||
| headerFields: nil | ||
| )! | ||
| return (response, Data()) | ||
| ) | ||
| return (response ?? HTTPURLResponse(), Data()) | ||
|
Comment on lines
142
to
+146
|
||
| } | ||
| } | ||
|
|
||
|
|
@@ -163,12 +167,13 @@ final class MockURLProtocol: URLProtocol, @unchecked Sendable { | |
| /// Sets the global `requestHandler` — use inside `.serialized` suites only. | ||
| static func stub(json: String, statusCode: Int = 200) { | ||
| requestHandler = { request in | ||
| let url = request.url ?? URL(string: "https://example.com")! | ||
| let response = HTTPURLResponse( | ||
|
Comment on lines
169
to
171
|
||
| url: request.url ?? URL(string: "https://example.com")!, | ||
| url: url, | ||
| statusCode: statusCode, | ||
| httpVersion: nil, | ||
| headerFields: ["Content-Type": "application/json"] | ||
| )! | ||
| ) ?? HTTPURLResponse() | ||
| return (response, Data(json.utf8)) | ||
|
Comment on lines
171
to
177
|
||
| } | ||
| } | ||
|
|
@@ -179,12 +184,13 @@ final class MockURLProtocol: URLProtocol, @unchecked Sendable { | |
| requestHandler = { request in | ||
| let path = request.url?.absoluteString ?? "" | ||
| let json = routes.first(where: { path.contains($0.key) })?.value ?? "{}" | ||
| let url = request.url ?? URL(string: "https://example.com")! | ||
| let response = HTTPURLResponse( | ||
|
Comment on lines
184
to
188
|
||
| url: request.url ?? URL(string: "https://example.com")!, | ||
| url: url, | ||
| statusCode: statusCode, | ||
| httpVersion: nil, | ||
| headerFields: ["Content-Type": "application/json"] | ||
| )! | ||
| ) ?? HTTPURLResponse() | ||
| return (response, Data(json.utf8)) | ||
|
Comment on lines
188
to
194
|
||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
URL(string: "https://example.com")!reintroducesforce_unwrappingand will likely keep SwiftLint failing. Prefer a non-force-unwrap fallback URL (e.g., nil-coalescing to a prevalidated static URL orURL(fileURLWithPath:)) so the handler stays lint-clean.