SwiftLint fixes. (#2899)

non_optional_string_data_conversion and static_over_final_class

* Revert Data -> String changes for upcoming rule change.
This commit is contained in:
Doug
2024-06-05 07:31:49 +01:00
committed by GitHub
parent 8498cbd039
commit c51593476c
7 changed files with 18 additions and 23 deletions
@@ -3,7 +3,7 @@
{
"identity" : "compound-design-tokens",
"kind" : "remoteSourceControl",
"location" : "https://github.com/element-hq/compound-design-tokens.git",
"location" : "https://github.com/element-hq/compound-design-tokens",
"state" : {
"revision" : "c3fff1f2b042295cd5f4bcf8d4fe68ec47ca4061",
"version" : "1.2.0"
@@ -191,7 +191,7 @@
{
"identity" : "sfsafesymbols",
"kind" : "remoteSourceControl",
"location" : "https://github.com/SFSafeSymbols/SFSafeSymbols.git",
"location" : "https://github.com/SFSafeSymbols/SFSafeSymbols",
"state" : {
"revision" : "7cca2d60925876b5953a2cf7341cd80fbeac983c",
"version" : "4.1.1"
@@ -21,12 +21,12 @@ import UIKit
import DeviceKit
#endif
final class UserAgentBuilder {
class func makeASCIIUserAgent() -> String {
enum UserAgentBuilder {
static func makeASCIIUserAgent() -> String {
makeUserAgent()?.asciified() ?? "unknown"
}
private class func makeUserAgent() -> String? {
static func makeUserAgent() -> String? {
let clientName = InfoPlistReader.app.bundleDisplayName
let clientVersion = InfoPlistReader.app.bundleShortVersionString
@@ -502,7 +502,7 @@ class RoomScreenInteractionHandler {
}
guard let audioPlayerState = audioPlayerState(for: itemID) else {
fatalError("Audio player not found for \(itemID)")
fatalError("Audio player state not found for \(itemID)")
}
// Ensure this one is attached
@@ -160,7 +160,7 @@ class MockScreen: Identifiable {
let context = LAContextMock()
context.biometryTypeValue = UIDevice.current.isPhone ? .faceID : .touchID // (iPhone 14 & iPad 9th gen)
context.evaluatePolicyReturnValue = true
context.evaluatedPolicyDomainStateValue = "😎".data(using: .utf8)
context.evaluatedPolicyDomainStateValue = Data("😎".utf8)
let appLockService = AppLockService(keychainController: keychainController,
appSettings: ServiceLocator.shared.settings,
@@ -215,7 +215,7 @@ class MockScreen: Identifiable {
let context = LAContextMock()
context.biometryTypeValue = UIDevice.current.isPhone ? .faceID : .touchID // (iPhone 14 & iPad 9th gen)
context.evaluatePolicyReturnValue = true
context.evaluatedPolicyDomainStateValue = "😎".data(using: .utf8)
context.evaluatedPolicyDomainStateValue = Data("😎".utf8)
let appLockService = AppLockService(keychainController: keychainController,
appSettings: ServiceLocator.shared.settings,
@@ -185,7 +185,7 @@ class AppLockServiceTests: XCTestCase {
// Given a service with the PIN code already set.
let context = LAContextMock()
context.biometryTypeValue = .touchID
context.evaluatedPolicyDomainStateValue = "👆".data(using: .utf8)
context.evaluatedPolicyDomainStateValue = Data("👆".utf8)
service = AppLockService(keychainController: keychainController, appSettings: appSettings, context: context)
guard case .success = service.setupPINCode("2023") else {
XCTFail("The PIN should be valid.")
@@ -217,7 +217,7 @@ class AppLockServiceTests: XCTestCase {
// Given a service with the PIN code already set.
let context = LAContextMock()
context.biometryTypeValue = .touchID
context.evaluatedPolicyDomainStateValue = "👆".data(using: .utf8)
context.evaluatedPolicyDomainStateValue = Data("👆".utf8)
service = AppLockService(keychainController: keychainController, appSettings: appSettings, context: context)
let pinCode = "2023"
guard case .success = service.setupPINCode(pinCode) else {
@@ -234,7 +234,7 @@ class AppLockServiceTests: XCTestCase {
XCTAssertTrue(service.biometricUnlockTrusted, "Biometric unlock should be trusted.")
// When the user changes biometric data.
context.evaluatedPolicyDomainStateValue = "👈".data(using: .utf8)
context.evaluatedPolicyDomainStateValue = Data("👈".utf8)
// Then biometric lock should remain enabled but untrusted.
XCTAssertTrue(service.isEnabled, "The service should remain enabled.")
@@ -256,7 +256,7 @@ class AppLockServiceTests: XCTestCase {
// Given a service with the PIN code already set.
let context = LAContextMock()
context.biometryTypeValue = .touchID
context.evaluatedPolicyDomainStateValue = "👆".data(using: .utf8)
context.evaluatedPolicyDomainStateValue = Data("👆".utf8)
service = AppLockService(keychainController: keychainController, appSettings: appSettings, context: context)
guard case .success = service.setupPINCode("2023") else {
XCTFail("The PIN should be valid.")
@@ -285,7 +285,7 @@ class AppLockServiceTests: XCTestCase {
// Given a service with the PIN code already set.
let context = LAContextMock()
context.biometryTypeValue = .touchID
context.evaluatedPolicyDomainStateValue = "👆".data(using: .utf8)
context.evaluatedPolicyDomainStateValue = Data("👆".utf8)
service = AppLockService(keychainController: keychainController, appSettings: appSettings, context: context)
guard case .success = service.setupPINCode("2023") else {
XCTFail("The PIN should be valid.")
@@ -170,7 +170,7 @@ class KeychainControllerTests: XCTestCase {
XCTAssertNil(keychain.pinCodeBiometricState(), "A new keychain shouldn't return biometric state.")
// When setting the state.
let data: Data! = "Face ID".data(using: .utf8)
let data = Data("Face ID".utf8)
try keychain.setPINCodeBiometricState(data)
// Then the state should be stored.
@@ -180,13 +180,13 @@ class KeychainControllerTests: XCTestCase {
func testUpdatePINCodeBiometricState() throws {
// Given a keychain that contains PIN code biometric state.
let data: Data! = "😃".data(using: .utf8)
let data = Data("😃".utf8)
try keychain.setPINCodeBiometricState(data)
XCTAssertTrue(keychain.containsPINCodeBiometricState(), "The keychain should contain the biometric state.")
XCTAssertEqual(keychain.pinCodeBiometricState(), data, "The stored biometric state should match what was set.")
// When setting different state.
let newData: Data! = "😎".data(using: .utf8)
let newData = Data("😎".utf8)
try keychain.setPINCodeBiometricState(newData)
// Then the state should be updated.
@@ -197,7 +197,7 @@ class KeychainControllerTests: XCTestCase {
func testRemovePINCodeBiometricState() throws {
// Given a keychain that contains PIN code biometric state.
let data: Data! = "Face ID".data(using: .utf8)
let data = Data("Face ID".utf8)
try keychain.setPINCodeBiometricState(data)
XCTAssertTrue(keychain.containsPINCodeBiometricState(), "The keychain should contain the biometric state.")
XCTAssertEqual(keychain.pinCodeBiometricState(), data, "The stored biometric state should match what was set.")
+1 -6
View File
@@ -294,12 +294,7 @@ class LoggingTests: XCTestCase {
let currentLogFile = logsFileDirectory.appending(path: "console.1.log")
let fileHandle = try FileHandle(forWritingTo: currentLogFile)
try fileHandle.seekToEnd()
guard let newLineData = "newline".data(using: .utf8) else {
XCTFail("Couldn't create data to write to disk.")
return
}
try fileHandle.write(contentsOf: newLineData)
try fileHandle.write(contentsOf: Data("newline".utf8))
try fileHandle.close()
// Then that file should now be the first log file.