diff --git a/Dangerfile.swift b/Dangerfile.swift index 33e538359..9a4f3707b 100644 --- a/Dangerfile.swift +++ b/Dangerfile.swift @@ -25,7 +25,7 @@ if danger.github.pullRequest.body?.isEmpty ?? true { } /// Check for screenshots on view changes -let hasChangedViews = !editedFiles.filter { $0.lowercased().contains("/view") }.isEmpty +let hasChangedViews = editedFiles.contains { $0.lowercased().contains("/view") } if hasChangedViews { if (danger.github.pullRequest.body?.contains("user-attachments") ?? false) == false { warn("You seem to have made changes to views. Please consider adding screenshots.") @@ -33,7 +33,7 @@ if hasChangedViews { } /// Check for pngs on resources -let hasPngs = !editedFiles.filter { $0.lowercased().contains(".xcassets") && $0.lowercased().hasSuffix(".png") }.isEmpty +let hasPngs = editedFiles.contains { $0.lowercased().contains(".xcassets") && $0.lowercased().hasSuffix(".png") } if hasPngs { warn("You seem to have made changes to some resource images. Please consider using an SVG or PDF.") } diff --git a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 332f73928..a386909c8 100644 --- a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "61e1de2b41c093a3c8796903827114a1435f5608a839ee17ba60d376e8f804f7", + "originHash" : "1c7d307d80ee561100a0432a5ae13f345392a1175c7f6c17c2eb0da269382c57", "pins" : [ { "identity" : "compound-design-tokens", diff --git a/ElementX/Sources/Other/BlurHashEncode.swift b/ElementX/Sources/Other/BlurHashEncode.swift index 01e240c4d..48baedfc9 100644 --- a/ElementX/Sources/Other/BlurHashEncode.swift +++ b/ElementX/Sources/Other/BlurHashEncode.swift @@ -75,7 +75,7 @@ extension UIImage { hash += sizeFlag.encode83(length: 1) let maximumValue: Float - if ac.count > 0 { + if !ac.isEmpty { let actualMaximumValue = ac.map { max(abs($0.0), abs($0.1), abs($0.2)) }.max()! let quantisedMaximumValue = Int(max(0, min(82, floor(actualMaximumValue * 166 - 0.5)))) maximumValue = Float(quantisedMaximumValue + 1) / 166 diff --git a/ElementX/Sources/Other/CollapsibleFlowLayout/CollapsibleReactionLayout.swift b/ElementX/Sources/Other/CollapsibleFlowLayout/CollapsibleReactionLayout.swift index f6cc1df6c..6161ed0bd 100644 --- a/ElementX/Sources/Other/CollapsibleFlowLayout/CollapsibleReactionLayout.swift +++ b/ElementX/Sources/Other/CollapsibleFlowLayout/CollapsibleReactionLayout.swift @@ -24,7 +24,7 @@ nonisolated struct CollapsibleReactionLayout: Layout { var rowsBeforeCollapsible: Int? func sizeThatFits(proposal: ProposedViewSize, subviews: some FlowLayoutSubviews, cache: inout ()) -> CGSize { - guard let subviewsByType = getSubviewsByItemType(subviews: Array(subviews)), subviewsByType.reactions.count > 0 else { + guard let subviewsByType = getSubviewsByItemType(subviews: Array(subviews)), !subviewsByType.reactions.isEmpty else { return .zero } @@ -53,7 +53,7 @@ nonisolated struct CollapsibleReactionLayout: Layout { } func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: some FlowLayoutSubviews, cache: inout ()) { - guard let subviewsByType = getSubviewsByItemType(subviews: Array(subviews)), subviewsByType.reactions.count > 0 else { + guard let subviewsByType = getSubviewsByItemType(subviews: Array(subviews)), !subviewsByType.reactions.isEmpty else { subviews.forEach { subview in subview.place(at: Self.pointOffscreen, anchor: .leading, proposal: .zero) } @@ -119,7 +119,7 @@ nonisolated struct CollapsibleReactionLayout: Layout { currentRow.append(subview) } // If there are items in the current row remember to append it to the returned value - if currentRow.count > 0 { + if !currentRow.isEmpty { rows.append(currentRow) } return rows @@ -243,7 +243,7 @@ nonisolated struct CollapsibleReactionLayout: Layout { addMoreButton = subview } } - guard let collapseButton, let addMoreButton, reactions.count > 0 else { + guard let collapseButton, let addMoreButton, !reactions.isEmpty else { return nil } return ReactionSubviews(reactions: reactions, collapseButton: collapseButton, addMoreButton: addMoreButton) diff --git a/ElementX/Sources/Other/Extensions/XCUIElement.swift b/ElementX/Sources/Other/Extensions/XCUIElement.swift index 686e4d043..82efb893f 100644 --- a/ElementX/Sources/Other/Extensions/XCUIElement.swift +++ b/ElementX/Sources/Other/Extensions/XCUIElement.swift @@ -40,7 +40,7 @@ extension XCUIApplication { /// app instance anyway, and some of our tests assert that a default focus has been set on the text field, /// so having a method that would set the focus and show the keyboard isn't always desirable. func showKeyboardIfNeeded() { - if UIDevice.current.userInterfaceIdiom == .pad, keyboards.count == 0 { + if UIDevice.current.userInterfaceIdiom == .pad, keyboards.isEmpty { buttons["Keyboard"].tap() buttons["Show Keyboard"].tap() } diff --git a/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilder.swift b/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilder.swift index 99d5a836f..489cdac75 100644 --- a/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilder.swift +++ b/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilder.swift @@ -347,7 +347,7 @@ nonisolated struct AttributedStringBuilder: AttributedStringBuilderProtocol { TextParsingMatch(type: .atRoom, range: match.range) }) - guard matches.count > 0 else { + guard !matches.isEmpty else { return } diff --git a/ElementX/Sources/Other/SwiftUI/Views/RoomAvatarImage.swift b/ElementX/Sources/Other/SwiftUI/Views/RoomAvatarImage.swift index 784662dce..ef3f800f1 100644 --- a/ElementX/Sources/Other/SwiftUI/Views/RoomAvatarImage.swift +++ b/ElementX/Sources/Other/SwiftUI/Views/RoomAvatarImage.swift @@ -68,7 +68,7 @@ struct RoomAvatarImage: View { onTap: onAvatarTap) case .heroes(let users): // We will expand upon this with more stack sizes in the future. - if users.count == 0 { + if users.isEmpty { let _ = assertionFailure("We should never pass empty heroes here.") PlaceholderAvatarImage(name: nil, contentID: "") } else if users.count == 2 { diff --git a/ElementX/Sources/Screens/CreateRoomScreen/View/CreateRoomSpaceSelectionSheet.swift b/ElementX/Sources/Screens/CreateRoomScreen/View/CreateRoomSpaceSelectionSheet.swift index f646265cb..4e5dcab68 100644 --- a/ElementX/Sources/Screens/CreateRoomScreen/View/CreateRoomSpaceSelectionSheet.swift +++ b/ElementX/Sources/Screens/CreateRoomScreen/View/CreateRoomSpaceSelectionSheet.swift @@ -78,6 +78,6 @@ struct CreateRoomSpaceSelectionSheet_Previews: PreviewProvider, TestablePreview static var previews: some View { CreateRoomSpaceSelectionSheet(context: viewModel.context) - .snapshotPreferences(expect: viewModel.context.$viewState.map { $0.editableSpaces.count > 0 }) + .snapshotPreferences(expect: viewModel.context.$viewState.map { !$0.editableSpaces.isEmpty }) } } diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenContent.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenContent.swift index 50716ff96..7c14bfcd6 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenContent.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenContent.swift @@ -142,7 +142,7 @@ struct HomeScreenContent: View { guard let scrollView = scrollViewAdapter.scrollView, scrollViewAdapter.isScrolling.value == false, // Ignore while scrolling context.searchQuery.isEmpty == true, // Ignore while filtering - context.viewState.visibleRooms.count > 0 else { + !context.viewState.visibleRooms.isEmpty else { return } diff --git a/ElementX/Sources/Screens/RoomMemberListScreen/RoomMembersListScreenModels.swift b/ElementX/Sources/Screens/RoomMemberListScreen/RoomMembersListScreenModels.swift index 776a8a8b8..502916f5b 100644 --- a/ElementX/Sources/Screens/RoomMemberListScreen/RoomMembersListScreenModels.swift +++ b/ElementX/Sources/Screens/RoomMemberListScreen/RoomMembersListScreenModels.swift @@ -81,7 +81,7 @@ struct RoomMembersListScreenViewState: BindableState { var shouldShowEmptyState: Bool { switch bindings.mode { case .banned: - visibleBannedMembers.count == 0 + visibleBannedMembers.isEmpty case .members: visibleInvitedMembers.count + visibleJoinedMembers.count == 0 } diff --git a/ElementX/Sources/Screens/RoomMemberListScreen/RoomMembersListScreenViewModel.swift b/ElementX/Sources/Screens/RoomMemberListScreen/RoomMembersListScreenViewModel.swift index 694805f3a..bc1fb4df5 100644 --- a/ElementX/Sources/Screens/RoomMemberListScreen/RoomMembersListScreenViewModel.swift +++ b/ElementX/Sources/Screens/RoomMemberListScreen/RoomMembersListScreenViewModel.swift @@ -105,7 +105,7 @@ class RoomMembersListScreenViewModel: RoomMembersListScreenViewModelType, RoomMe self.currentUserProxy = members.first { $0.userID == roomProxy.ownUserID } var newBindings = state.bindings - if roomMembersDetails.bannedMembers.count == 0 { + if roomMembersDetails.bannedMembers.isEmpty { newBindings.mode = .members } self.state = .init(joinedMembersCount: roomProxy.infoPublisher.value.joinedMembersCount, diff --git a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/MessageComposerTextField.swift b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/MessageComposerTextField.swift index 75b6b1ca1..c3c723fb3 100644 --- a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/MessageComposerTextField.swift +++ b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/MessageComposerTextField.swift @@ -279,7 +279,7 @@ private class ElementTextView: UITextView, PillAttachmentViewProviderDelegate { return false } - return UIPasteboard.general.itemProviders.filter { !$0.isSupportedForPasteOrDrop }.isEmpty + return !UIPasteboard.general.itemProviders.contains { !$0.isSupportedForPasteOrDrop } } override func paste(_ sender: Any?) { @@ -293,7 +293,7 @@ private class ElementTextView: UITextView, PillAttachmentViewProviderDelegate { let providers = UIPasteboard.general.itemProviders // Use the default behavior if there are any unsupported providers - guard providers.filter({ !$0.isSupportedForPasteOrDrop }).isEmpty else { + guard !providers.contains(where: { !$0.isSupportedForPasteOrDrop }) else { super.paste(sender) return } diff --git a/ElementX/Sources/Screens/Spaces/SpaceAddRoomsScreen/SpaceAddRoomsScreenModels.swift b/ElementX/Sources/Screens/Spaces/SpaceAddRoomsScreen/SpaceAddRoomsScreenModels.swift index 4b63389fe..b486bbb39 100644 --- a/ElementX/Sources/Screens/Spaces/SpaceAddRoomsScreen/SpaceAddRoomsScreenModels.swift +++ b/ElementX/Sources/Screens/Spaces/SpaceAddRoomsScreen/SpaceAddRoomsScreenModels.swift @@ -82,7 +82,7 @@ private extension RoomInfoProxyProtocol { return alias } - guard heroes.count > 0 else { + guard !heroes.isEmpty else { return "" } diff --git a/ElementX/Sources/Screens/Spaces/SpaceScreen/View/SpaceScreen.swift b/ElementX/Sources/Screens/Spaces/SpaceScreen/View/SpaceScreen.swift index c1d28a41b..c5c9204d7 100644 --- a/ElementX/Sources/Screens/Spaces/SpaceScreen/View/SpaceScreen.swift +++ b/ElementX/Sources/Screens/Spaces/SpaceScreen/View/SpaceScreen.swift @@ -136,7 +136,7 @@ struct SpaceScreen: View { } .accessibilityIdentifier(A11yIdentifiers.spaceScreen.addExistingRooms) - if context.viewState.rooms.count > 0 { + if !context.viewState.rooms.isEmpty { Button { context.send(viewAction: .manageChildren) } label: { Label(L10n.actionManageRooms, icon: \.edit) } diff --git a/ElementX/Sources/Services/Room/RoomInfoProxyProtocol.swift b/ElementX/Sources/Services/Room/RoomInfoProxyProtocol.swift index 91c848483..85a33c4df 100644 --- a/ElementX/Sources/Services/Room/RoomInfoProxyProtocol.swift +++ b/ElementX/Sources/Services/Room/RoomInfoProxyProtocol.swift @@ -116,12 +116,12 @@ extension RoomInfoProxyProtocol { // Check if the canonical alias matches the homeserver if let canonicalAlias, - canonicalAlias.range(of: serverName) != nil { + canonicalAlias.contains(serverName) { return canonicalAlias } // Otherwise check the alternative aliases and return the first one that matches - if let matchingAlternativeAlias = alternativeAliases.first(where: { $0.range(of: serverName) != nil }) { + if let matchingAlternativeAlias = alternativeAliases.first(where: { $0.contains(serverName) }) { return matchingAlternativeAlias } diff --git a/ElementX/Sources/Services/Room/RoomSummary/RoomSummary.swift b/ElementX/Sources/Services/Room/RoomSummary/RoomSummary.swift index dc5ae313f..0c704d42e 100644 --- a/ElementX/Sources/Services/Room/RoomSummary/RoomSummary.swift +++ b/ElementX/Sources/Services/Room/RoomSummary/RoomSummary.swift @@ -103,7 +103,7 @@ nonisolated extension RoomSummary: CustomStringConvertible { return alias } - guard heroes.count > 0 else { + guard !heroes.isEmpty else { return "" } diff --git a/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactory.swift b/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactory.swift index 85a7cda2d..5d4157cb6 100644 --- a/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactory.swift +++ b/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactory.swift @@ -861,7 +861,7 @@ nonisolated struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol { canBeRepliedTo: eventItemProxy.canBeRepliedTo, isDM: isDM, isDeclinedByMe: declinedBy.contains(userID), - isDeclined: declinedBy.count > 0, + isDeclined: !declinedBy.isEmpty, isVoiceCall: isVoiceCall, properties: .init()) } diff --git a/IntegrationTests/Sources/Application.swift b/IntegrationTests/Sources/Application.swift index 913d314d8..f60facdc2 100644 --- a/IntegrationTests/Sources/Application.swift +++ b/IntegrationTests/Sources/Application.swift @@ -26,7 +26,7 @@ enum Application { extension XCUIApplication { var homeserver: String? { guard let homeserver = ProcessInfo.processInfo.environment["INTEGRATION_TESTS_HOST"], - homeserver.count > 0 else { + !homeserver.isEmpty else { return nil } @@ -35,7 +35,7 @@ extension XCUIApplication { var username: String { guard let username = ProcessInfo.processInfo.environment["INTEGRATION_TESTS_USERNAME"], - username.count > 0 else { + !username.isEmpty else { return "default" } @@ -44,7 +44,7 @@ extension XCUIApplication { var password: String { guard let password = ProcessInfo.processInfo.environment["INTEGRATION_TESTS_PASSWORD"], - password.count > 0 else { + !password.isEmpty else { return "default" } diff --git a/IntegrationTests/Sources/Common.swift b/IntegrationTests/Sources/Common.swift index f7ea5e9b6..c53d5b30e 100644 --- a/IntegrationTests/Sources/Common.swift +++ b/IntegrationTests/Sources/Common.swift @@ -64,7 +64,7 @@ extension XCUIApplication { throw IntegrationTestsError.webAuthenticationSessionFailure } - if alerts.count > 0 { + if !alerts.isEmpty { alerts.firstMatch.buttons["OK"].firstMatch.tap() } } diff --git a/UITests/Sources/AuthenticationFlowCoordinatorTests.swift b/UITests/Sources/AuthenticationFlowCoordinatorTests.swift index 1171359e3..c6cda2abb 100644 --- a/UITests/Sources/AuthenticationFlowCoordinatorTests.swift +++ b/UITests/Sources/AuthenticationFlowCoordinatorTests.swift @@ -150,7 +150,7 @@ class AuthenticationFlowCoordinatorUITests: XCTestCase { XCTFail("Failed to present the web authentication session.") } - if app.alerts.count > 0 { + if !app.alerts.isEmpty { app.alerts.firstMatch.buttons["OK"].tap() } } diff --git a/UnitTests/Sources/ChatsTabFlowCoordinatorTests.swift b/UnitTests/Sources/ChatsTabFlowCoordinatorTests.swift index 8ac4fdecd..651e686b9 100644 --- a/UnitTests/Sources/ChatsTabFlowCoordinatorTests.swift +++ b/UnitTests/Sources/ChatsTabFlowCoordinatorTests.swift @@ -207,7 +207,7 @@ struct ChatsTabFlowCoordinatorTests { mutating func roomClearsStack() async throws { try await process(route: .room(roomID: "1", via: []), expectedState: .roomList(detailState: .room(roomID: "1"))) #expect(detailNavigationStack?.rootCoordinator is RoomScreenCoordinator) - #expect(detailNavigationStack?.stackCoordinators.count == 0) + #expect(detailNavigationStack?.stackCoordinators.isEmpty == true) #expect(detailCoordinator != nil) chatsTabFlowCoordinator.handleAppRoute(.childRoom(roomID: "2", via: []), animated: true) @@ -219,7 +219,7 @@ struct ChatsTabFlowCoordinatorTests { try await process(route: .room(roomID: "3", via: []), expectedState: .roomList(detailState: .room(roomID: "3"))) #expect(detailNavigationStack?.rootCoordinator is RoomScreenCoordinator) - #expect(detailNavigationStack?.stackCoordinators.count == 0) + #expect(detailNavigationStack?.stackCoordinators.isEmpty == true) #expect(detailCoordinator != nil) } @@ -228,7 +228,7 @@ struct ChatsTabFlowCoordinatorTests { // A regular event route should set its room as the root of the stack and focus on the event. try await process(route: .event(eventID: "1", roomID: "1", via: []), expectedState: .roomList(detailState: .room(roomID: "1"))) #expect(detailNavigationStack?.rootCoordinator is RoomScreenCoordinator) - #expect(detailNavigationStack?.stackCoordinators.count == 0) + #expect(detailNavigationStack?.stackCoordinators.isEmpty == true) #expect(detailCoordinator != nil) #expect(timelineControllerFactory.buildTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryMediaProviderCallsCount == 1) #expect(timelineControllerFactory.buildTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryMediaProviderReceivedArguments?.initialFocussedEventID == "1") @@ -246,7 +246,7 @@ struct ChatsTabFlowCoordinatorTests { // A subsequent regular event route should clear the stack and set the new room as the root of the stack. try await process(route: .event(eventID: "3", roomID: "3", via: []), expectedState: .roomList(detailState: .room(roomID: "3"))) #expect(detailNavigationStack?.rootCoordinator is RoomScreenCoordinator) - #expect(detailNavigationStack?.stackCoordinators.count == 0) + #expect(detailNavigationStack?.stackCoordinators.isEmpty == true) #expect(detailCoordinator != nil) #expect(timelineControllerFactory.buildTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryMediaProviderCallsCount == 3) #expect(timelineControllerFactory.buildTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryMediaProviderReceivedArguments?.initialFocussedEventID == "3") @@ -254,7 +254,7 @@ struct ChatsTabFlowCoordinatorTests { // A regular event route for the same room should set a new instance of the room as the root of the stack. try await process(route: .event(eventID: "4", roomID: "3", via: []), expectedState: .roomList(detailState: .room(roomID: "3"))) #expect(detailNavigationStack?.rootCoordinator is RoomScreenCoordinator) - #expect(detailNavigationStack?.stackCoordinators.count == 0) + #expect(detailNavigationStack?.stackCoordinators.isEmpty == true) #expect(detailCoordinator != nil) #expect(timelineControllerFactory.buildTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryMediaProviderCallsCount == 4) #expect(timelineControllerFactory.buildTimelineControllerRoomProxyInitialFocussedEventIDTimelineItemFactoryMediaProviderReceivedArguments?.initialFocussedEventID == "4", diff --git a/UnitTests/Sources/RoomFlowCoordinatorTests.swift b/UnitTests/Sources/RoomFlowCoordinatorTests.swift index ff3394e1b..0cd48db16 100644 --- a/UnitTests/Sources/RoomFlowCoordinatorTests.swift +++ b/UnitTests/Sources/RoomFlowCoordinatorTests.swift @@ -68,7 +68,7 @@ final class RoomFlowCoordinatorTests { try await process(route: .room(roomID: "1", via: [])) #expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator) - #expect(navigationStackCoordinator.stackCoordinators.count == 0) + #expect(navigationStackCoordinator.stackCoordinators.isEmpty) try await process(route: .roomDetails(roomID: "1")) #expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator) @@ -82,7 +82,7 @@ final class RoomFlowCoordinatorTests { try await process(route: .room(roomID: "1", via: [])) #expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator) - #expect(navigationStackCoordinator.stackCoordinators.count == 0) + #expect(navigationStackCoordinator.stackCoordinators.isEmpty) try await process(route: .childRoom(roomID: "2", via: [])) #expect(navigationStackCoordinator.stackCoordinators.count == 1) @@ -95,7 +95,7 @@ final class RoomFlowCoordinatorTests { try await clearRoute(expectedActions: [.finished]) #expect(navigationStackCoordinator.rootCoordinator == nil) - #expect(navigationStackCoordinator.stackCoordinators.count == 0) + #expect(navigationStackCoordinator.stackCoordinators.isEmpty) } /// Tests the child flow teardown in isolation of it's parent. @@ -124,7 +124,7 @@ final class RoomFlowCoordinatorTests { try await process(route: .room(roomID: "1", via: [])) #expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator) - #expect(navigationStackCoordinator.stackCoordinators.count == 0) + #expect(navigationStackCoordinator.stackCoordinators.isEmpty) try await process(route: .childRoom(roomID: "2", via: [])) #expect(navigationStackCoordinator.stackCoordinators.count == 1) @@ -142,10 +142,10 @@ final class RoomFlowCoordinatorTests { try await process(route: .room(roomID: "1", via: [])) #expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator) - #expect(navigationStackCoordinator.stackCoordinators.count == 0) + #expect(navigationStackCoordinator.stackCoordinators.isEmpty) try await process(route: .childRoom(roomID: "1", via: [])) - #expect(navigationStackCoordinator.stackCoordinators.count == 0, + #expect(navigationStackCoordinator.stackCoordinators.isEmpty, "A room flow shouldn't present a direct child for the same room.") try await process(route: .childRoom(roomID: "2", via: [])) @@ -165,7 +165,7 @@ final class RoomFlowCoordinatorTests { try await process(route: .room(roomID: "InvitedRoomID", via: [])) #expect(navigationStackCoordinator.rootCoordinator is JoinRoomScreenCoordinator) - #expect(navigationStackCoordinator.stackCoordinators.count == 0) + #expect(navigationStackCoordinator.stackCoordinators.isEmpty) try await clearRoute(expectedActions: [.finished]) #expect(navigationStackCoordinator.rootCoordinator == nil) @@ -174,7 +174,7 @@ final class RoomFlowCoordinatorTests { try await process(route: .room(roomID: "InvitedRoomID", via: [])) #expect(navigationStackCoordinator.rootCoordinator is JoinRoomScreenCoordinator) - #expect(navigationStackCoordinator.stackCoordinators.count == 0) + #expect(navigationStackCoordinator.stackCoordinators.isEmpty) // "Join" the room clientProxy.roomForIdentifierClosure = { _ in @@ -183,7 +183,7 @@ final class RoomFlowCoordinatorTests { try await process(route: .room(roomID: "InvitedRoomID", via: [])) #expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator) - #expect(navigationStackCoordinator.stackCoordinators.count == 0) + #expect(navigationStackCoordinator.stackCoordinators.isEmpty) } @Test @@ -224,11 +224,11 @@ final class RoomFlowCoordinatorTests { try await process(route: .event(eventID: "1", roomID: "1", via: [])) #expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator) - #expect(navigationStackCoordinator.stackCoordinators.count == 0) + #expect(navigationStackCoordinator.stackCoordinators.isEmpty) try await process(route: .childEvent(eventID: "2", roomID: "1", via: [])) #expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator) - #expect(navigationStackCoordinator.stackCoordinators.count == 0) + #expect(navigationStackCoordinator.stackCoordinators.isEmpty) try await process(route: .childEvent(eventID: "3", roomID: "2", via: [])) #expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator) @@ -324,13 +324,13 @@ final class RoomFlowCoordinatorTests { try await process(route: .room(roomID: "1", via: [])) #expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator) - #expect(navigationStackCoordinator.stackCoordinators.count == 0) + #expect(navigationStackCoordinator.stackCoordinators.isEmpty) let sharePayload: ShareExtensionPayload = .mediaFiles(roomID: "1", mediaFiles: [.init(url: .picturesDirectory, suggestedName: nil)]) try await process(route: .share(sharePayload)) #expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator) - #expect(navigationStackCoordinator.stackCoordinators.count == 0) + #expect(navigationStackCoordinator.stackCoordinators.isEmpty) #expect((navigationStackCoordinator.sheetCoordinator as? NavigationStackCoordinator)?.rootCoordinator is MediaUploadPreviewScreenCoordinator) @@ -340,7 +340,7 @@ final class RoomFlowCoordinatorTests { try await process(route: .share(sharePayload)) - #expect(navigationStackCoordinator.stackCoordinators.count == 0) + #expect(navigationStackCoordinator.stackCoordinators.isEmpty) #expect((navigationStackCoordinator.sheetCoordinator as? NavigationStackCoordinator)?.rootCoordinator is MediaUploadPreviewScreenCoordinator) } @@ -350,13 +350,13 @@ final class RoomFlowCoordinatorTests { try await process(route: .room(roomID: "1", via: [])) #expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator) - #expect(navigationStackCoordinator.stackCoordinators.count == 0) + #expect(navigationStackCoordinator.stackCoordinators.isEmpty) let sharePayload: ShareExtensionPayload = .text(roomID: "1", text: "Important text") try await process(route: .share(sharePayload)) #expect(navigationStackCoordinator.rootCoordinator is RoomScreenCoordinator) - #expect(navigationStackCoordinator.stackCoordinators.count == 0) + #expect(navigationStackCoordinator.stackCoordinators.isEmpty) #expect(navigationStackCoordinator.sheetCoordinator == nil, "The media upload sheet shouldn't be shown when sharing text.") @@ -366,7 +366,7 @@ final class RoomFlowCoordinatorTests { try await process(route: .share(sharePayload)) - #expect(navigationStackCoordinator.stackCoordinators.count == 0) + #expect(navigationStackCoordinator.stackCoordinators.isEmpty) #expect(navigationStackCoordinator.sheetCoordinator == nil, "The media upload sheet shouldn't be shown when sharing text.") } diff --git a/UnitTests/Sources/RoomMembersListScreenViewModelTests.swift b/UnitTests/Sources/RoomMembersListScreenViewModelTests.swift index fc48ce15d..6b7c000de 100644 --- a/UnitTests/Sources/RoomMembersListScreenViewModelTests.swift +++ b/UnitTests/Sources/RoomMembersListScreenViewModelTests.swift @@ -79,7 +79,7 @@ struct RoomMembersListScreenViewModelTests { try await deferred.fulfill() #expect(viewModel.state.joinedMembersCount == 2) - #expect(viewModel.state.visibleJoinedMembers.count == 0) + #expect(viewModel.state.visibleJoinedMembers.isEmpty) } @Test @@ -107,7 +107,7 @@ struct RoomMembersListScreenViewModelTests { #expect(viewModel.state.joinedMembersCount == 0) #expect(viewModel.state.visibleInvitedMembers.count == 1) - #expect(viewModel.state.visibleJoinedMembers.count == 0) + #expect(viewModel.state.visibleJoinedMembers.isEmpty) } @Test @@ -122,7 +122,7 @@ struct RoomMembersListScreenViewModelTests { #expect(viewModel.state.joinedMembersCount == 0) #expect(viewModel.state.visibleInvitedMembers.count == 1) - #expect(viewModel.state.visibleJoinedMembers.count == 0) + #expect(viewModel.state.visibleJoinedMembers.isEmpty) } @Test @@ -286,7 +286,7 @@ struct RoomMembersListScreenViewModelTests { context.mode = .banned try await deferred.fulfill() - deferred = deferFulfillment(context.$viewState) { $0.visibleBannedMembers.count == 0 && $0.bindings.mode == .members } + deferred = deferFulfillment(context.$viewState) { $0.visibleBannedMembers.isEmpty && $0.bindings.mode == .members } subject.value = [RoomMemberProxyMock].allMembersAsAdmin try await deferred.fulfill() } diff --git a/UnitTests/Sources/RoomScreenViewModelTests.swift b/UnitTests/Sources/RoomScreenViewModelTests.swift index d6dd7454c..00cb9f77d 100644 --- a/UnitTests/Sources/RoomScreenViewModelTests.swift +++ b/UnitTests/Sources/RoomScreenViewModelTests.swift @@ -51,7 +51,7 @@ final class RoomScreenViewModelTests { // check if in the default state is not showing but is indeed loading var deferred = deferFulfillment(viewModel.context.$viewState) { viewState in - viewState.pinnedEventsBannerState.count == 0 + viewState.pinnedEventsBannerState.isEmpty } try await deferred.fulfill() #expect(viewModel.context.viewState.pinnedEventsBannerState.isLoading) diff --git a/UnitTests/Sources/SecurityAndPrivacyScreenViewModelTests.swift b/UnitTests/Sources/SecurityAndPrivacyScreenViewModelTests.swift index 63d99c2b4..3ffed9108 100644 --- a/UnitTests/Sources/SecurityAndPrivacyScreenViewModelTests.swift +++ b/UnitTests/Sources/SecurityAndPrivacyScreenViewModelTests.swift @@ -96,7 +96,7 @@ final class SecurityAndPrivacyScreenViewModelTests { let space = singleRoom[0] setupViewModel(joinedParentSpaces: [], joinRule: .restricted(rules: [.roomMembership(roomID: space.id)])) - let deferred = deferFulfillment(context.$viewState) { $0.selectableJoinedSpaces.count == 0 } + let deferred = deferFulfillment(context.$viewState) { $0.selectableJoinedSpaces.isEmpty } try await deferred.fulfill() #expect(context.viewState.currentSettings.accessType == .spaceMembers(spaceIDs: [space.id])) diff --git a/UnitTests/Sources/SpaceListScreenViewModelTests.swift b/UnitTests/Sources/SpaceListScreenViewModelTests.swift index 1978bd4a9..7e3a12964 100644 --- a/UnitTests/Sources/SpaceListScreenViewModelTests.swift +++ b/UnitTests/Sources/SpaceListScreenViewModelTests.swift @@ -53,10 +53,10 @@ final class SpacesScreenViewModelTests { @Test func topLevelSpacesSubscription() async throws { - var deferred = deferFulfillment(context.observe(\.viewState.topLevelSpaces)) { $0.count == 0 } + var deferred = deferFulfillment(context.observe(\.viewState.topLevelSpaces)) { $0.isEmpty } topLevelSpacesSubject.send([]) try await deferred.fulfill() - #expect(context.viewState.topLevelSpaces.count == 0) + #expect(context.viewState.topLevelSpaces.isEmpty) deferred = deferFulfillment(context.observe(\.viewState.topLevelSpaces)) { $0.count == 1 } topLevelSpacesSubject.send([ diff --git a/UnitTests/Sources/UserIndicatorControllerTests.swift b/UnitTests/Sources/UserIndicatorControllerTests.swift index db626ab7b..039576ceb 100644 --- a/UnitTests/Sources/UserIndicatorControllerTests.swift +++ b/UnitTests/Sources/UserIndicatorControllerTests.swift @@ -39,7 +39,7 @@ struct UserIndicatorControllerTests { indicatorController.retractAllIndicators() - #expect(indicatorController.indicatorQueue.count == 0) + #expect(indicatorController.indicatorQueue.isEmpty) } @Test @@ -94,7 +94,7 @@ struct UserIndicatorControllerTests { try await fulfillment.fulfill() - #expect(indicatorController.indicatorQueue.count == 0) + #expect(indicatorController.indicatorQueue.isEmpty) #expect(indicatorController.activeIndicator == nil) } }