Skip to content

Commit

Permalink
Fixed SwiftLint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tobihagemann committed Sep 12, 2024
1 parent 9a7743f commit a1b40bf
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class VaultFormat6ShortenedNameCache {
return Promise(originalName)
} else {
return loadLngFile(shortenedName).then { data -> String in
let originalName = String(decoding: data, as: UTF8.self)
let originalName = String(data: data, encoding: .utf8)!
try? self.addToCache(shortenedName, originalName: originalName)
return originalName
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class VaultFormat7ShortenedNameCache {
return Promise(originalName)
} else {
return loadNameC9S(c9sDirPath).then { data -> String in
let originalName = String(decoding: data, as: UTF8.self)
let originalName = String(data: data, encoding: .utf8)!
try? self.addToCache(shortenedName, originalName: originalName)
return originalName
}
Expand Down
2 changes: 0 additions & 2 deletions Sources/CryptomatorCloudAccess/Logging/HTTPDebugLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ enum HTTPDebugLogger {
guard let bodyData = request.httpBody else {
return .none
}
// swiftlint:disable:next non_optional_string_data_conversion
if let body = String(data: bodyData, encoding: .utf8) {
if body.isEmpty {
return .empty
Expand Down Expand Up @@ -103,7 +102,6 @@ enum HTTPDebugLogger {
if let contentEncodingHeaderField = response.value(forHTTPHeaderField: "Content-Encoding"), contentEncodingHeaderField.caseInsensitiveCompare("identity") != .orderedSame {
return .encoded
}
// swiftlint:disable:next non_optional_string_data_conversion
if let body = String(data: bodyData, encoding: .utf8) {
if body.isEmpty {
return .empty
Expand Down
2 changes: 1 addition & 1 deletion Tests/CryptomatorCloudAccessTests/Crypto/CryptorMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class CryptorMock: Cryptor {
}

override public func encryptDirId(_ dirId: Data) throws -> String {
if let dirId = dirIds[String(decoding: dirId, as: UTF8.self)] {
if let dirId = dirIds[String(data: dirId, encoding: .utf8)!] {
return dirId
} else {
return "99ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class VaultConfigTests: XCTestCase {
let vaultConfig = VaultConfig(id: "ABB9F673-F3E8-41A7-A43B-D29F5DA65068", format: 8, cipherCombo: .sivCtrMac, shorteningThreshold: 220)
let rawKey = [UInt8](repeating: 0x55, count: 64)
let token = try vaultConfig.toToken(keyId: "masterkeyfile:masterkey.cryptomator", rawKey: rawKey)
let tokenComponents = String(decoding: token, as: UTF8.self).split(separator: ".")
let tokenComponents = String(data: token, encoding: .utf8)!.split(separator: ".")
// check header
let header: [String: String] = try decodeTokenComponent(String(tokenComponents[0]))
XCTAssertEqual(["typ": "JWT", "alg": "HS256", "kid": "masterkeyfile:masterkey.cryptomator"], header)
Expand Down

0 comments on commit a1b40bf

Please sign in to comment.