Skip to content

Commit

Permalink
Fix remaining SwiftLint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ninxsoft committed Oct 5, 2024
1 parent bafffe5 commit c91e662
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
14 changes: 12 additions & 2 deletions Mist/Extensions/Sequence+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ extension Sequence where Iterator.Element == [String: Any] {
/// - Returns: A JSON string representation.
func jsonString() throws -> String {
let data: Data = try JSONSerialization.data(withJSONObject: self, options: [.prettyPrinted, .sortedKeys])
return String(decoding: data, as: UTF8.self)

guard let string: String = String(data: data, encoding: .utf8) else {
throw MistError.invalidData
}

return string
}

/// Provides a Property List string representation.
Expand All @@ -40,7 +45,12 @@ extension Sequence where Iterator.Element == [String: Any] {
/// - Returns: A Property List string representation.
func propertyListString() throws -> String {
let data: Data = try PropertyListSerialization.data(fromPropertyList: self, format: .xml, options: .bitWidth)
return String(decoding: data, as: UTF8.self)

guard let string: String = String(data: data, encoding: .utf8) else {
throw MistError.invalidData
}

return string
}

/// Provides a YAML string representation.
Expand Down
2 changes: 1 addition & 1 deletion Mist/Views/Activity/ActivityView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ struct ActivityView: View {
}

private func checkForUserCancellation(_ failure: Error) -> Bool {
if failure as? CancellationError != nil {
if failure is CancellationError {
return true
}

Expand Down
2 changes: 1 addition & 1 deletion Mist/Views/Refresh/RefreshView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ struct RefreshView: View {
var value: [String: Any] = value as? [String: Any],
let date: Date = value["PostDate"] as? Date,
let extendedMetaInfo: [String: Any] = value["ExtendedMetaInfo"] as? [String: Any],
extendedMetaInfo["InstallAssistantPackageIdentifiers"] as? [String: Any] != nil,
extendedMetaInfo["InstallAssistantPackageIdentifiers"] is [String: Any],
let distributions: [String: Any] = value["Distributions"] as? [String: Any],
let distributionURL: String = distributions["English"] as? String,
let url: URL = URL(string: distributionURL) else {
Expand Down

0 comments on commit c91e662

Please sign in to comment.