Skip to content

Commit

Permalink
Removing Dead Code part 1 (#2234)
Browse files Browse the repository at this point in the history
  • Loading branch information
Velin92 authored Dec 13, 2023
1 parent 09b276d commit d99d26f
Show file tree
Hide file tree
Showing 88 changed files with 115 additions and 477 deletions.
4 changes: 2 additions & 2 deletions .periphery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ targets:
- UITests
- UnitTests
report_exclude:
# includes subscript which is not detectable: https://github.com/apple/swift/issues/56541
- ElementX/Sources/Screens/Settings/AvancedOptionsScreen/AdvancedSettingsScreenModels.swift
- ElementX/Sources/Mocks/Generated/GeneratedMocks.swift
- ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift
verbose: true
retain_swift_ui_previews: true
8 changes: 0 additions & 8 deletions ElementX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@
50539366B408780B232C1910 /* EstimatedWaveformView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD0FF64B0E6470F66F42E182 /* EstimatedWaveformView.swift */; };
50C90117FE25390BFBD40173 /* RustTracing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 542D4F49FABA056DEEEB3400 /* RustTracing.swift */; };
5100F53E6884A15F9BA07CC3 /* AttributedStringTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37CA26F55123E36B50DB0B3A /* AttributedStringTests.swift */; };
516534FC5C893D57F169D5A8 /* MapTilerGeocoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33720F7AD25E85E4A84669E8 /* MapTilerGeocoding.swift */; };
518C93DC6516D3D018DE065F /* UNNotificationRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49E751D7EDB6043238111D90 /* UNNotificationRequest.swift */; };
51C240F4660F7269203A9B3A /* MigrationScreenUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75910F5A36EA8FF9BAD08D18 /* MigrationScreenUITests.swift */; };
520EEDAFBC778AB0B41F2F53 /* ClientMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADE6170EFE6A161B0A68AB61 /* ClientMock.swift */; };
Expand Down Expand Up @@ -852,7 +851,6 @@
D8385A51A3D0FA9283556281 /* RoundedLabelItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 745323FCF9AF21A117252C53 /* RoundedLabelItem.swift */; };
D871C8CF46950F959C9A62C3 /* WelcomeScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = C54464351F170D570110AFCA /* WelcomeScreen.swift */; };
D876EC0FED3B6D46C806912A /* AvatarSize.swift in Sources */ = {isa = PBXBuildFile; fileRef = E24B88AD3D1599E8CB1376E0 /* AvatarSize.swift */; };
D8CFF02C2730EE5BC4F17ABF /* ElementToggleStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0960A7F5C1B0B6679BDF26F9 /* ElementToggleStyle.swift */; };
D9473FC9B077A6EDB7A12001 /* LocationRoomTimelineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 772334731A8BF8E6D90B194D /* LocationRoomTimelineView.swift */; };
D98B5EE8C4F5A2CE84687AE8 /* UTType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 897DF5E9A70CE05A632FC8AF /* UTType.swift */; };
D9F80CE61BF8FF627FDB0543 /* LoadableImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C352359663A0E52BA20761EE /* LoadableImage.swift */; };
Expand Down Expand Up @@ -1088,7 +1086,6 @@
086B997409328F091EBA43CE /* RoomScreenUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomScreenUITests.swift; sourceTree = "<group>"; };
086C19086DD16E9B38E25954 /* ReportContentViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportContentViewModelTests.swift; sourceTree = "<group>"; };
095AED4CF56DFF3EB7BB84C8 /* RoomTimelineProviderProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomTimelineProviderProtocol.swift; sourceTree = "<group>"; };
0960A7F5C1B0B6679BDF26F9 /* ElementToggleStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ElementToggleStyle.swift; sourceTree = "<group>"; };
099F2D36C141D845A445B1E6 /* EmojiProviderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiProviderTests.swift; sourceTree = "<group>"; };
09CE2B7AD979BDEE09FEDB08 /* WaitlistScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WaitlistScreenModels.swift; sourceTree = "<group>"; };
0A3E77399BD262D301451BF2 /* RoomDetailsEditScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomDetailsEditScreenCoordinator.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1243,7 +1240,6 @@
32C5DAA1773F57653BF1C4F9 /* SoftLogoutViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SoftLogoutViewModelTests.swift; sourceTree = "<group>"; };
33649299575BADC34924ABC6 /* InvitesScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InvitesScreenCoordinator.swift; sourceTree = "<group>"; };
3368395F06AA180138E185B6 /* PollFormScreenUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PollFormScreenUITests.swift; sourceTree = "<group>"; };
33720F7AD25E85E4A84669E8 /* MapTilerGeocoding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapTilerGeocoding.swift; sourceTree = "<group>"; };
33E49C5C6F802B4D94CA78D1 /* ro */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ro; path = ro.lproj/Localizable.strings; sourceTree = "<group>"; };
340179A0FC1AD4AEDA7FC134 /* CreateRoomViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateRoomViewModelProtocol.swift; sourceTree = "<group>"; };
342BEBC3C5FC3F9943C41C4C /* TemplateScreenViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateScreenViewModelProtocol.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2511,7 +2507,6 @@
CC743C7A85E3171BCBF0A653 /* AvatarHeaderView.swift */,
C1FA515B3B0D61EF1E907D2D /* BadgeView.swift */,
8CC23C63849452BC86EA2852 /* ButtonStyle.swift */,
0960A7F5C1B0B6679BDF26F9 /* ElementToggleStyle.swift */,
7EC2F1622C5BBABED6012E12 /* HeroImage.swift */,
B590BD4507D4F0A377FDE01A /* LoadableAvatarImage.swift */,
C352359663A0E52BA20761EE /* LoadableImage.swift */,
Expand Down Expand Up @@ -4267,7 +4262,6 @@
B81B6170DB690013CEB646F4 /* MapLibreModels.swift */,
592A35163B0749C66BFD6186 /* MapLibreStaticMapView.swift */,
E062C1750EFC8627DE4CAB8E /* MapTilerAuthorization.swift */,
33720F7AD25E85E4A84669E8 /* MapTilerGeocoding.swift */,
C23B3FAD8B23C421BC0D1B1E /* MapTilerGeoCodingServiceProtocol.swift */,
1A4D29F2683F5772AC72406F /* MapTilerStaticMap.swift */,
20872C3887F835958CE2F1D0 /* MapTilerStaticMapProtocol.swift */,
Expand Down Expand Up @@ -5490,7 +5484,6 @@
FE4593FC2A02AAF92E089565 /* ElementAnimations.swift in Sources */,
07CC13C5729C24255348CBBD /* ElementCallWidgetDriver.swift in Sources */,
370AF5BFCD4384DD455479B6 /* ElementCallWidgetDriverProtocol.swift in Sources */,
D8CFF02C2730EE5BC4F17ABF /* ElementToggleStyle.swift in Sources */,
7C1A7B594B2F8143F0DD0005 /* ElementXAttributeScope.swift in Sources */,
7361B011A79BF723D8C9782B /* EmojiCategory.swift in Sources */,
E45C9FA22BC13B477FD3B4AC /* EmojiDetection.swift in Sources */,
Expand Down Expand Up @@ -5598,7 +5591,6 @@
D181AC8FF236B7F91C0A8C28 /* MapTiler.swift in Sources */,
FCDA202B246F75BA28E10C5F /* MapTilerAuthorization.swift in Sources */,
7ABAB3A1D52B86FACF2F74CF /* MapTilerGeoCodingServiceProtocol.swift in Sources */,
516534FC5C893D57F169D5A8 /* MapTilerGeocoding.swift in Sources */,
D6661A94DBD97658B2ADBD6A /* MapTilerStaticMap.swift in Sources */,
7B5DAB915357BE596529BF25 /* MapTilerStaticMapProtocol.swift in Sources */,
83A4DAB181C56987C3E804FF /* MapTilerStyle.swift in Sources */,
Expand Down

This file was deleted.

This file was deleted.

13 changes: 7 additions & 6 deletions ElementX/Sources/Application/AppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,

private var authenticationCoordinator: AuthenticationCoordinator?
private let appLockFlowCoordinator: AppLockFlowCoordinator
// periphery:ignore - used to avoid deallocation
private var appLockSetupFlowCoordinator: AppLockSetupFlowCoordinator?
private var userSessionFlowCoordinator: UserSessionFlowCoordinator?
private var softLogoutCoordinator: SoftLogoutScreenCoordinator?
Expand Down Expand Up @@ -90,7 +91,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,

navigationRootCoordinator = NavigationRootCoordinator()

Self.setupServiceLocator(navigationRootCoordinator: navigationRootCoordinator, appSettings: appSettings)
Self.setupServiceLocator(appSettings: appSettings)

ServiceLocator.shared.analytics.startIfEnabled()

Expand Down Expand Up @@ -209,9 +210,9 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,

// MARK: - AuthenticationCoordinatorDelegate

func authenticationCoordinator(_ authenticationCoordinator: AuthenticationCoordinator, didLoginWithSession userSession: UserSessionProtocol) {
func authenticationCoordinator(didLoginWithSession userSession: UserSessionProtocol) {
self.userSession = userSession
self.authenticationCoordinator = nil
authenticationCoordinator = nil
stateMachine.processEvent(.createdUserSession)
}

Expand All @@ -232,7 +233,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,
UIApplication.shared.unregisterForRemoteNotifications()
}

func shouldDisplayInAppNotification(_ service: NotificationManagerProtocol, content: UNNotificationContent) -> Bool {
func shouldDisplayInAppNotification(content: UNNotificationContent) -> Bool {
guard let roomID = content.roomID else {
return true
}
Expand All @@ -243,7 +244,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,
return !userSessionFlowCoordinator.isDisplayingRoomScreen(withRoomID: roomID)
}

func notificationTapped(_ service: NotificationManagerProtocol, content: UNNotificationContent) async {
func notificationTapped(content: UNNotificationContent) async {
MXLog.info("[AppCoordinator] tappedNotification")

guard let roomID = content.roomID,
Expand Down Expand Up @@ -284,7 +285,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,
setenv("RUST_BACKTRACE", "1", 1)
}

private static func setupServiceLocator(navigationRootCoordinator: NavigationRootCoordinator, appSettings: AppSettings) {
private static func setupServiceLocator(appSettings: AppSettings) {
ServiceLocator.shared.register(userIndicatorController: UserIndicatorController())
ServiceLocator.shared.register(appSettings: appSettings)
ServiceLocator.shared.register(networkMonitor: NetworkMonitor())
Expand Down
1 change: 0 additions & 1 deletion ElementX/Sources/Application/AppCoordinatorProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import Foundation

protocol AppCoordinatorProtocol: CoordinatorProtocol {
var notificationManager: NotificationManagerProtocol { get }
var windowManager: WindowManager { get }
@discardableResult func handleDeepLink(_ url: URL) -> Bool
}
6 changes: 0 additions & 6 deletions ElementX/Sources/Application/AppSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ final class AppSettings {
/// deleted between runs so should clear data in the shared container and keychain.
@UserPreference(key: UserDefaultsKeys.lastVersionLaunched, storageType: .userDefaults(store))
var lastVersionLaunched: String?

let lastLaunchDate = Date()

/// The Set of room identifiers of invites that the user already saw in the invites list.
/// This Set is being used to implement badges for unread invites.
Expand Down Expand Up @@ -180,7 +178,6 @@ final class AppSettings {
let bugReportSentryURL: URL = "https://f39ac49e97714316965b777d9f3d6cd8@sentry.tools.element.io/44"
// Use the name allocated by the bug report server
let bugReportApplicationId = "element-x-ios"
let bugReportUISIId = "element-auto-uisi"
/// The maximum size of the upload request. Default value is just below CloudFlare's max request size.
let bugReportMaxUploadSize = 50 * 1024 * 1024

Expand Down Expand Up @@ -257,9 +254,6 @@ final class AppSettings {
// maptiler api key
let mapTilerApiKey = InfoPlistReader.main.mapLibreAPIKey

// maptiler geocoding url
let geocodingURLFormatString = "https://api.maptiler.com/geocoding/%f,%f.json"

// MARK: - Feature Flags

@UserPreference(key: UserDefaultsKeys.userSuggestionsEnabled, defaultValue: false, storageType: .volatile)
Expand Down
1 change: 1 addition & 0 deletions ElementX/Sources/Application/FlowCoordinatorProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import Foundation

// periphery:ignore - markdown protocol
@MainActor
protocol FlowCoordinatorProtocol {
func handleAppRoute(_ appRoute: AppRoute, animated: Bool)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ class AppLockFlowCoordinator: CoordinatorProtocol {

private let stateMachine: StateMachine<State, Event>

/// A task used to await biometric unlock before showing the PIN screen.
@CancellableTask private var unlockTask: Task<Void, Never>?
private var cancellables: Set<AnyCancellable> = []

/// Whether or not biometric unlock should be attempted instead of asking for a PIN.
Expand Down
1 change: 0 additions & 1 deletion ElementX/Sources/Generated/Assets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ internal enum Asset {
internal static let addLocation = ImageAsset(name: "images/add-location")
internal static let attachment = ImageAsset(name: "images/attachment")
internal static let takePhoto = ImageAsset(name: "images/take-photo")
internal static let textFormatting = ImageAsset(name: "images/text-formatting")
internal static let bold = ImageAsset(name: "images/bold")
internal static let bulletList = ImageAsset(name: "images/bullet-list")
internal static let closeRte = ImageAsset(name: "images/close-rte")
Expand Down
12 changes: 0 additions & 12 deletions ElementX/Sources/Mocks/ApplicationMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,6 @@ extension ApplicationMock {
underlyingApplicationState = applicationState
underlyingBackgroundTimeRemaining = backgroundTimeRemaining

beginBackgroundTaskExpirationHandlerClosure = { [weak self] handler in
guard let self else {
return .invalid
}

guard allowTasks else {
return .invalid
}

return beginBackgroundTask(withName: nil, expirationHandler: handler)
}

beginBackgroundTaskWithNameExpirationHandlerClosure = { _, handler in
guard allowTasks else {
return .invalid
Expand Down
57 changes: 0 additions & 57 deletions ElementX/Sources/Mocks/Generated/GeneratedMocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,6 @@ class AnalyticsClientMock: AnalyticsClientProtocol {
stopCallsCount += 1
stopClosure?()
}
//MARK: - flush

var flushCallsCount = 0
var flushCalled: Bool {
return flushCallsCount > 0
}
var flushClosure: (() -> Void)?

func flush() {
flushCallsCount += 1
flushClosure?()
}
//MARK: - capture

var captureCallsCount = 0
Expand Down Expand Up @@ -100,22 +88,6 @@ class AnalyticsClientMock: AnalyticsClientProtocol {
screenReceivedInvocations.append(event)
screenClosure?(event)
}
//MARK: - updateUserProperties

var updateUserPropertiesCallsCount = 0
var updateUserPropertiesCalled: Bool {
return updateUserPropertiesCallsCount > 0
}
var updateUserPropertiesReceivedUserProperties: AnalyticsEvent.UserProperties?
var updateUserPropertiesReceivedInvocations: [AnalyticsEvent.UserProperties] = []
var updateUserPropertiesClosure: ((AnalyticsEvent.UserProperties) -> Void)?

func updateUserProperties(_ userProperties: AnalyticsEvent.UserProperties) {
updateUserPropertiesCallsCount += 1
updateUserPropertiesReceivedUserProperties = userProperties
updateUserPropertiesReceivedInvocations.append(userProperties)
updateUserPropertiesClosure?(userProperties)
}
}
class AppLockServiceMock: AppLockServiceProtocol {
var isMandatory: Bool {
Expand Down Expand Up @@ -323,23 +295,6 @@ class ApplicationMock: ApplicationProtocol {

//MARK: - beginBackgroundTask

var beginBackgroundTaskExpirationHandlerCallsCount = 0
var beginBackgroundTaskExpirationHandlerCalled: Bool {
return beginBackgroundTaskExpirationHandlerCallsCount > 0
}
var beginBackgroundTaskExpirationHandlerReturnValue: UIBackgroundTaskIdentifier!
var beginBackgroundTaskExpirationHandlerClosure: (((() -> Void)?) -> UIBackgroundTaskIdentifier)?

func beginBackgroundTask(expirationHandler handler: (() -> Void)?) -> UIBackgroundTaskIdentifier {
beginBackgroundTaskExpirationHandlerCallsCount += 1
if let beginBackgroundTaskExpirationHandlerClosure = beginBackgroundTaskExpirationHandlerClosure {
return beginBackgroundTaskExpirationHandlerClosure(handler)
} else {
return beginBackgroundTaskExpirationHandlerReturnValue
}
}
//MARK: - beginBackgroundTask

var beginBackgroundTaskWithNameExpirationHandlerCallsCount = 0
var beginBackgroundTaskWithNameExpirationHandlerCalled: Bool {
return beginBackgroundTaskWithNameExpirationHandlerCallsCount > 0
Expand Down Expand Up @@ -739,18 +694,6 @@ class BugReportServiceMock: BugReportServiceProtocol {
resetCallsCount += 1
resetClosure?()
}
//MARK: - crash

var crashCallsCount = 0
var crashCalled: Bool {
return crashCallsCount > 0
}
var crashClosure: (() -> Void)?

func crash() {
crashCallsCount += 1
crashClosure?()
}
//MARK: - submitBugReport

var submitBugReportProgressListenerCallsCount = 0
Expand Down
4 changes: 0 additions & 4 deletions ElementX/Sources/Other/AvatarSize.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ enum RoomAvatarSizeOnScreen {
}

extension AvatarSize {
var size: CGSize {
CGSize(width: value, height: value)
}

var scaledSize: CGSize {
CGSize(width: scaledValue, height: scaledValue)
}
Expand Down
6 changes: 0 additions & 6 deletions ElementX/Sources/Other/BlurHashDecode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,6 @@ private extension String {
self[index(startIndex, offsetBy: offset)]
}

subscript(bounds: CountableClosedRange<Int>) -> Substring {
let start = index(startIndex, offsetBy: bounds.lowerBound)
let end = index(startIndex, offsetBy: bounds.upperBound)
return self[start...end]
}

subscript(bounds: CountableRange<Int>) -> Substring {
let start = index(startIndex, offsetBy: bounds.lowerBound)
let end = index(startIndex, offsetBy: bounds.upperBound)
Expand Down
1 change: 1 addition & 0 deletions ElementX/Sources/Other/CancellableTask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import Foundation

// periphery:ignore - property wrappers generate false positives
@propertyWrapper
struct CancellableTask<S: Sendable, F: Error> {
private var storedValue: Task<S, F>?
Expand Down
Loading

0 comments on commit d99d26f

Please sign in to comment.