Fix various swiftlint and swiftformat warnings
This commit is contained in:
committed by
Stefan Ceriu
parent
e5bcc34a24
commit
5cf3a4477e
@@ -5,6 +5,7 @@
|
||||
--disable wrapMultiLineStatementBraces
|
||||
--disable hoistPatternLet
|
||||
--disable preferForLoop
|
||||
--disable consistentSwitchCaseSpacing
|
||||
|
||||
--commas inline
|
||||
--ifdef no-indent
|
||||
|
||||
@@ -22,7 +22,7 @@ extension Dictionary {
|
||||
options: [.fragmentsAllowed, .sortedKeys]) else {
|
||||
return nil
|
||||
}
|
||||
return String(data: data, encoding: .utf8)
|
||||
return String(decoding: data, as: UTF8.self)
|
||||
}
|
||||
|
||||
/// Returns a dictionary containing the original values keyed by the results of mapping the given closure over its keys.
|
||||
|
||||
@@ -474,6 +474,7 @@ class RoomScreenInteractionHandler {
|
||||
|
||||
// MARK: Audio Playback
|
||||
|
||||
// swiftlint:disable:next cyclomatic_complexity
|
||||
func playPauseAudio(for itemID: TimelineItemIdentifier) async {
|
||||
MXLog.info("Toggle play/pause audio for itemID \(itemID)")
|
||||
guard let timelineItem = timelineController.timelineItems.firstUsingStableID(itemID) else {
|
||||
|
||||
@@ -175,14 +175,14 @@ class BugReportService: NSObject, BugReportServiceProtocol {
|
||||
let (data, response) = try await session.dataWithRetry(for: request, delegate: self)
|
||||
|
||||
guard let httpResponse = response as? HTTPURLResponse else {
|
||||
let errorDescription = String(data: data, encoding: .utf8)?.trimmingCharacters(in: .whitespacesAndNewlines) ?? "Unknown"
|
||||
let errorDescription = String(decoding: data, as: UTF8.self).trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
MXLog.error("Failed to submit bug report: \(errorDescription)")
|
||||
MXLog.error("Response: \(response)")
|
||||
return .failure(.serverError(response, errorDescription))
|
||||
}
|
||||
|
||||
guard httpResponse.statusCode == 200 else {
|
||||
let errorDescription = String(data: data, encoding: .utf8)?.trimmingCharacters(in: .whitespacesAndNewlines) ?? "Unknown"
|
||||
let errorDescription = String(decoding: data, as: UTF8.self).trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
MXLog.error("Failed to submit bug report: \(errorDescription) (\(httpResponse.statusCode))")
|
||||
MXLog.error("Response: \(httpResponse)")
|
||||
return .failure(.httpError(httpResponse, errorDescription))
|
||||
|
||||
@@ -159,7 +159,7 @@ struct TimelineItemDebugInfo: Identifiable, CustomStringConvertible {
|
||||
return nil
|
||||
}
|
||||
|
||||
return String(data: jsonData, encoding: .utf8)
|
||||
return String(decoding: jsonData, as: UTF8.self)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -146,11 +146,10 @@ enum UITestsSignalling {
|
||||
let encoder = JSONEncoder()
|
||||
encoder.outputFormatting = .sortedKeys
|
||||
|
||||
guard let data = try? encoder.encode(self),
|
||||
let string = String(data: data, encoding: .utf8) else {
|
||||
guard let data = try? encoder.encode(self) else {
|
||||
return "unknown"
|
||||
}
|
||||
return string
|
||||
return String(decoding: data, as: UTF8.self)
|
||||
}
|
||||
|
||||
init?(rawValue: String) {
|
||||
@@ -175,7 +174,7 @@ enum UITestsSignalling {
|
||||
|
||||
/// Processes string data from the file and publishes its signal.
|
||||
private func processFileData(_ data: Data) {
|
||||
guard let rawMessage = String(data: data, encoding: .utf8) else { return }
|
||||
let rawMessage = String(decoding: data, as: UTF8.self)
|
||||
|
||||
guard let message = Message(rawValue: rawMessage),
|
||||
message.mode != mode // Filter out messages sent by this client.
|
||||
|
||||
Reference in New Issue
Block a user