mirror of
https://github.com/ninxsoft/Mist.git
synced 2025-05-27 13:34:37 -04:00
Fix SwiftLint warnings
This commit is contained in:
parent
c63356ff40
commit
f53361cfc6
7 changed files with 14 additions and 25 deletions
|
@ -19,12 +19,12 @@ extension Sequence where Iterator.Element == [String: Any] {
|
|||
|
||||
func jsonString() throws -> String {
|
||||
let data: Data = try JSONSerialization.data(withJSONObject: self, options: [.prettyPrinted, .sortedKeys])
|
||||
return String(data: data, encoding: .utf8) ?? ""
|
||||
return String(decoding: data, as: UTF8.self)
|
||||
}
|
||||
|
||||
func propertyListString() throws -> String {
|
||||
let data: Data = try PropertyListSerialization.data(fromPropertyList: self, format: .xml, options: .bitWidth)
|
||||
return String(data: data, encoding: .utf8) ?? ""
|
||||
return String(decoding: data, as: UTF8.self)
|
||||
}
|
||||
|
||||
func yamlString() throws -> String {
|
||||
|
|
|
@ -31,13 +31,8 @@ enum PropertyListUpdater {
|
|||
}
|
||||
|
||||
propertyList[key] = value
|
||||
|
||||
data = try PropertyListSerialization.data(fromPropertyList: propertyList, format: .xml, options: .bitWidth)
|
||||
|
||||
guard let output = String(data: data, encoding: .utf8) else {
|
||||
throw MistError.invalidData
|
||||
}
|
||||
|
||||
let output: String = .init(decoding: data, as: UTF8.self)
|
||||
try output.write(to: url, atomically: true, encoding: .utf8)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,10 +125,9 @@ struct Firmware: Decodable, Hashable, Identifiable {
|
|||
return []
|
||||
}
|
||||
|
||||
let string: String = try String(contentsOf: url)
|
||||
let (data, _): (Data, URLResponse) = try await URLSession.shared.data(from: url)
|
||||
|
||||
guard
|
||||
let data: Data = string.data(using: .utf8),
|
||||
let dictionary: [String: Any] = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [String: Any],
|
||||
let array: [[String: Any]] = dictionary["firmwares"] as? [[String: Any]] else {
|
||||
return []
|
||||
|
|
|
@ -68,11 +68,11 @@ enum Hardware {
|
|||
guard
|
||||
let dictionary: [String: Any] = nsDictionary as? [String: Any],
|
||||
dictionary.keys.contains(key),
|
||||
let data: Data = IORegistryEntryCreateCFProperty(entry, key as CFString, kCFAllocatorDefault, 0).takeRetainedValue() as? Data,
|
||||
let string: String = String(data: data, encoding: .utf8) else {
|
||||
let data: Data = IORegistryEntryCreateCFProperty(entry, key as CFString, kCFAllocatorDefault, 0).takeRetainedValue() as? Data else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let string: String = .init(decoding: data, as: UTF8.self)
|
||||
return string.trimmingCharacters(in: CharacterSet(["\0"]))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,6 +116,7 @@ struct ActivityView: View {
|
|||
title: Text("Are you sure you want to cancel?"),
|
||||
message: Text("This process cannot be resumed once it has been cancelled."),
|
||||
primaryButton: .default(Text("Resume")),
|
||||
// swiftlint:disable:next trailing_closure
|
||||
secondaryButton: .destructive(Text("Cancel"), action: { cancel() })
|
||||
)
|
||||
case .error:
|
||||
|
|
|
@ -106,11 +106,9 @@ struct RefreshView: View {
|
|||
throw MistError.invalidURL(Firmware.firmwaresURL)
|
||||
}
|
||||
|
||||
let string: String = try String(contentsOf: firmwaresURL, encoding: .utf8)
|
||||
let (data, _): (Data, URLResponse) = try await URLSession.shared.data(from: firmwaresURL)
|
||||
|
||||
guard
|
||||
let data: Data = string.data(using: .utf8),
|
||||
let dictionary: [String: Any] = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [String: Any] else {
|
||||
guard let dictionary: [String: Any] = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [String: Any] else {
|
||||
throw MistError.invalidData
|
||||
}
|
||||
|
||||
|
@ -163,12 +161,7 @@ struct RefreshView: View {
|
|||
}
|
||||
|
||||
do {
|
||||
let string: String = try String(contentsOf: url, encoding: .utf8)
|
||||
|
||||
guard let data: Data = string.data(using: .utf8) else {
|
||||
continue
|
||||
}
|
||||
|
||||
let (data, _): (Data, URLResponse) = try await URLSession.shared.data(from: url)
|
||||
var format: PropertyListSerialization.PropertyListFormat = .xml
|
||||
|
||||
guard
|
||||
|
@ -257,7 +250,8 @@ struct RefreshView: View {
|
|||
}
|
||||
|
||||
do {
|
||||
let string: String = try String(contentsOf: url, encoding: .utf8)
|
||||
let (data, _): (Data, URLResponse) = try await URLSession.shared.data(from: url)
|
||||
let string: String = .init(decoding: data, as: UTF8.self)
|
||||
|
||||
guard
|
||||
let name: String = nameFromDistribution(string),
|
||||
|
|
|
@ -51,9 +51,9 @@ class ShellExecutor: NSObject {
|
|||
process.waitUntilExit()
|
||||
|
||||
let outputData: Data = outputPipe.fileHandleForReading.readDataToEndOfFile()
|
||||
let standardOutput: String? = String(data: outputData, encoding: .utf8)
|
||||
let standardOutput: String = .init(decoding: outputData, as: UTF8.self)
|
||||
let errorData: Data = errorPipe.fileHandleForReading.readDataToEndOfFile()
|
||||
let standardError: String? = String(data: errorData, encoding: .utf8)
|
||||
let standardError: String = .init(decoding: errorData, as: UTF8.self)
|
||||
let terminationStatus: Int32 = process.terminationStatus
|
||||
return HelperToolCommandResponse(terminationStatus: terminationStatus, standardOutput: standardOutput, standardError: standardError)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue