Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwiftLint fixes. #2899

Merged
merged 3 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions ElementX/Sources/Other/UserAgentBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions ElementX/Sources/UITests/UITestsAppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions UnitTests/Sources/AppLock/AppLockServiceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -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 {
Expand All @@ -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.")
Expand All @@ -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.")
Expand Down Expand Up @@ -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.")
Expand Down
8 changes: 4 additions & 4 deletions UnitTests/Sources/KeychainControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.")
Expand Down
7 changes: 1 addition & 6 deletions UnitTests/Sources/LoggingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading