diff options
| author | Christian Cleberg <[email protected]> | 2026-04-13 20:07:53 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-04-13 20:07:53 -0500 |
| commit | 312e535f400f31714b3750de5222a1f6a8e5bcda (patch) | |
| tree | dfa0d9dfcfd08187befa79cf5d8afc4da9fef860 /Hutch/Views | |
| parent | fe1ccc69661603d419a642a450e4ac9e1258adb0 (diff) | |
| download | hutch-3.1.4.tar.gz hutch-3.1.4.tar.bz2 hutch-3.1.4.zip | |
fix: sonarqube code smell fixesv3.1.4
Diffstat (limited to 'Hutch/Views')
20 files changed, 123 insertions, 133 deletions
diff --git a/Hutch/Views/Builds/BuildDetailView.swift b/Hutch/Views/Builds/BuildDetailView.swift index 46fb42d..334dff7 100644 --- a/Hutch/Views/Builds/BuildDetailView.swift +++ b/Hutch/Views/Builds/BuildDetailView.swift @@ -468,7 +468,7 @@ private struct EditResubmitBuildSheet: View { _manifest = State(initialValue: job.manifest ?? "") _tagsText = State(initialValue: job.tags.joined(separator: ", ")) _note = State(initialValue: job.note ?? "") - _visibility = State(initialValue: job.visibility ?? .public) + _visibility = State(initialValue: job.visibility ?? .publicVisibility) } var body: some View { @@ -491,9 +491,9 @@ private struct EditResubmitBuildSheet: View { .autocorrectionDisabled() .themedRow() Picker("Visibility", selection: $visibility) { - Text("Public").tag(Visibility.public) + Text("Public").tag(Visibility.publicVisibility) Text("Unlisted").tag(Visibility.unlisted) - Text("Private").tag(Visibility.private) + Text("Private").tag(Visibility.privateVisibility) } .themedRow() Toggle("Start build now", isOn: $execute) diff --git a/Hutch/Views/Builds/BuildListView.swift b/Hutch/Views/Builds/BuildListView.swift index fc91ea1..8de2220 100644 --- a/Hutch/Views/Builds/BuildListView.swift +++ b/Hutch/Views/Builds/BuildListView.swift @@ -265,7 +265,7 @@ private struct SubmitBuildSheet: View { @State private var note = "" @State private var secrets = false @State private var execute = true - @State private var visibility: Visibility = .public + @State private var visibility: Visibility = .publicVisibility init(viewModel: BuildListViewModel, onSubmitted: @escaping (Int) -> Void) { self.viewModel = viewModel @@ -293,9 +293,9 @@ private struct SubmitBuildSheet: View { .autocorrectionDisabled() .themedRow() Picker("Visibility", selection: $visibility) { - Text("Public").tag(Visibility.public) + Text("Public").tag(Visibility.publicVisibility) Text("Unlisted").tag(Visibility.unlisted) - Text("Private").tag(Visibility.private) + Text("Private").tag(Visibility.privateVisibility) } .themedRow() Toggle("Start build now", isOn: $execute) diff --git a/Hutch/Views/Lookup/LookupView.swift b/Hutch/Views/Lookup/LookupView.swift index f45082d..64ca39d 100644 --- a/Hutch/Views/Lookup/LookupView.swift +++ b/Hutch/Views/Lookup/LookupView.swift @@ -233,15 +233,17 @@ final class LookupViewModel { let repository = try await appState.resolveRepository(owner: owner, name: name, service: service) let resolvedRepository = RepositorySummary( - id: repository.id, - rid: repository.rid, - service: service, - name: repository.name, - description: repository.description, - visibility: repository.visibility, - updated: repository.updated, - owner: repository.owner, - head: repository.head + fields: .init( + id: repository.id, + rid: repository.rid, + service: service, + name: repository.name, + description: repository.description, + visibility: repository.visibility, + updated: repository.updated, + owner: repository.owner, + head: repository.head + ) ) return .repository(resolvedRepository) diff --git a/Hutch/Views/Lookup/UserProfileViewModel.swift b/Hutch/Views/Lookup/UserProfileViewModel.swift index b88d36a..0e503ce 100644 --- a/Hutch/Views/Lookup/UserProfileViewModel.swift +++ b/Hutch/Views/Lookup/UserProfileViewModel.swift @@ -179,15 +179,17 @@ final class UserProfileViewModel { func repositorySummary(service: SRHTService) -> RepositorySummary { RepositorySummary( - id: id, - rid: rid, - service: service, - name: name, - description: description, - visibility: visibility, - updated: updated, - owner: owner, - head: head + fields: .init( + id: id, + rid: rid, + service: service, + name: name, + description: description, + visibility: visibility, + updated: updated, + owner: owner, + head: head + ) ) } } diff --git a/Hutch/Views/Pastes/PasteDetailView.swift b/Hutch/Views/Pastes/PasteDetailView.swift index c6fe11a..49d4fa6 100644 --- a/Hutch/Views/Pastes/PasteDetailView.swift +++ b/Hutch/Views/Pastes/PasteDetailView.swift @@ -442,27 +442,27 @@ private struct PasteVisibilitySheet: View { } private var visibilityOptions: [Visibility] { - [.public, .unlisted, .private] + [.publicVisibility, .unlisted, .privateVisibility] } private func title(for visibility: Visibility) -> String { switch visibility { - case .public: + case .publicVisibility: "Public" case .unlisted: "Unlisted" - case .private: + case .privateVisibility: "Private" } } private func description(for visibility: Visibility) -> String { switch visibility { - case .public: + case .publicVisibility: "Visible to everyone and listed on your profile." case .unlisted: "Visible to anyone with the URL, but not listed on your profile." - case .private: + case .privateVisibility: "Visible only to explicitly allowed viewers." } } diff --git a/Hutch/Views/Pastes/PasteListView.swift b/Hutch/Views/Pastes/PasteListView.swift index dfd472b..17bb8ac 100644 --- a/Hutch/Views/Pastes/PasteListView.swift +++ b/Hutch/Views/Pastes/PasteListView.swift @@ -179,33 +179,33 @@ struct PasteListView: View { private func nextVisibilityLabel(for visibility: Visibility) -> String { switch visibility { - case .public: + case .publicVisibility: return "Make Unlisted" case .unlisted: return "Make Private" - case .private: + case .privateVisibility: return "Make Public" } } private func nextVisibilityIcon(for visibility: Visibility) -> String { switch visibility { - case .public: + case .publicVisibility: return "eye.slash" case .unlisted: return "lock" - case .private: + case .privateVisibility: return "globe" } } private func nextVisibilityColor(for visibility: Visibility) -> Color { switch visibility { - case .public: + case .publicVisibility: return .orange case .unlisted: return .red - case .private: + case .privateVisibility: return .green } } @@ -316,9 +316,9 @@ private struct CreatePasteSheet: View { Section("Visibility") { Picker("Visibility", selection: $visibility) { - Text("Public").tag(Visibility.public) + Text("Public").tag(Visibility.publicVisibility) Text("Unlisted").tag(Visibility.unlisted) - Text("Private").tag(Visibility.private) + Text("Private").tag(Visibility.privateVisibility) } .themedRow() } diff --git a/Hutch/Views/Pastes/PasteListViewModel.swift b/Hutch/Views/Pastes/PasteListViewModel.swift index 75f2f4b..640e31b 100644 --- a/Hutch/Views/Pastes/PasteListViewModel.swift +++ b/Hutch/Views/Pastes/PasteListViewModel.swift @@ -131,12 +131,12 @@ final class PasteListViewModel { func cycleVisibility(for paste: Paste) async { let next: Visibility switch paste.visibility { - case .public: + case .publicVisibility: next = .unlisted case .unlisted: - next = .private - case .private: - next = .public + next = .privateVisibility + case .privateVisibility: + next = .publicVisibility } let original = pastes diff --git a/Hutch/Views/Repositories/FileTreeViewModel.swift b/Hutch/Views/Repositories/FileTreeViewModel.swift index c6fecbe..98211bf 100644 --- a/Hutch/Views/Repositories/FileTreeViewModel.swift +++ b/Hutch/Views/Repositories/FileTreeViewModel.swift @@ -327,14 +327,11 @@ final class FileTreeViewModel { } case .binaryBlob(let blob): - if blob.content != nil { + if blob.content != nil || blob.id == nil { viewingEntry = entry viewingObject = object } else if let blobId = blob.id { await loadBlob(entry: entry, blobId: blobId) - } else { - viewingEntry = entry - viewingObject = object } case .unknown: diff --git a/Hutch/Views/Repositories/HgRepositorySettingsView.swift b/Hutch/Views/Repositories/HgRepositorySettingsView.swift index e3c97e0..7b57505 100644 --- a/Hutch/Views/Repositories/HgRepositorySettingsView.swift +++ b/Hutch/Views/Repositories/HgRepositorySettingsView.swift @@ -121,9 +121,9 @@ struct HgRepositorySettingsView: View { .themedRow() Picker("Visibility", selection: Bindable(viewModel).editedVisibility) { - Text("Public").tag(Visibility.public) + Text("Public").tag(Visibility.publicVisibility) Text("Unlisted").tag(Visibility.unlisted) - Text("Private").tag(Visibility.private) + Text("Private").tag(Visibility.privateVisibility) } .themedRow() diff --git a/Hutch/Views/Repositories/ReadmeView.swift b/Hutch/Views/Repositories/ReadmeView.swift index 21d7a74..1a72b70 100644 --- a/Hutch/Views/Repositories/ReadmeView.swift +++ b/Hutch/Views/Repositories/ReadmeView.swift @@ -1828,7 +1828,7 @@ private final class HTMLWebViewCoordinator: NSObject, WKNavigationDelegate, @unc } func webView( - _ webView: WKWebView, + _: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping @MainActor (WKNavigationActionPolicy) -> Void ) { diff --git a/Hutch/Views/Repositories/RepositoryListView.swift b/Hutch/Views/Repositories/RepositoryListView.swift index 08ebb5c..04a7084 100644 --- a/Hutch/Views/Repositories/RepositoryListView.swift +++ b/Hutch/Views/Repositories/RepositoryListView.swift @@ -214,7 +214,7 @@ private struct CreateRepositorySheet: View { @State private var name = "" @State private var description = "" @State private var cloneURL = "" - @State private var visibility: Visibility = .public + @State private var visibility: Visibility = .publicVisibility @State private var service: RepositoryCreationService = .git var body: some View { @@ -235,9 +235,9 @@ private struct CreateRepositorySheet: View { .lineLimit(2...4) .themedRow() Picker("Visibility", selection: $visibility) { - Text("Public").tag(Visibility.public) + Text("Public").tag(Visibility.publicVisibility) Text("Unlisted").tag(Visibility.unlisted) - Text("Private").tag(Visibility.private) + Text("Private").tag(Visibility.privateVisibility) } .themedRow() } diff --git a/Hutch/Views/Repositories/RepositoryListViewModel.swift b/Hutch/Views/Repositories/RepositoryListViewModel.swift index 1e830bb..61053a0 100644 --- a/Hutch/Views/Repositories/RepositoryListViewModel.swift +++ b/Hutch/Views/Repositories/RepositoryListViewModel.swift @@ -397,15 +397,17 @@ final class RepositoryListViewModel { func repositorySummary(service: SRHTService) -> RepositorySummary { RepositorySummary( - id: id, - rid: rid, - service: service, - name: name, - description: description, - visibility: visibility, - updated: updated, - owner: owner, - head: head + fields: .init( + id: id, + rid: rid, + service: service, + name: name, + description: description, + visibility: visibility, + updated: updated, + owner: owner, + head: head + ) ) } } @@ -422,15 +424,17 @@ final class RepositoryListViewModel { func repositorySummary(service: SRHTService) -> RepositorySummary { RepositorySummary( - id: id, - rid: rid, - service: service, - name: name, - description: description, - visibility: visibility, - updated: updated, - owner: owner, - head: tip.map { Reference(name: $0.branch, target: nil) } + fields: .init( + id: id, + rid: rid, + service: service, + name: name, + description: description, + visibility: visibility, + updated: updated, + owner: owner, + head: tip.map { Reference(name: $0.branch, target: nil) } + ) ) } } @@ -463,17 +467,7 @@ final class RepositoryListViewModel { } if useCache && cursor == nil { - switch service { - case .git: - let result = try await client.executeAndCache( - service: service, - query: Self.gitQuery, - variables: variables.isEmpty ? nil : variables, - responseType: RepositoriesResponse.self, - cacheKey: cacheKey(for: service) - ) - return result.repositories ?? Self.emptyPage - case .hg: + if service == .hg { let hgVariables = cursor.map { ["cursor": $0 as any Sendable] } let result = try await client.executeAndCache( service: service, @@ -497,27 +491,17 @@ final class RepositoryListViewModel { } ?? [], cursor: result.repositories?.cursor ) - default: - let result = try await client.executeAndCache( - service: service, - query: Self.gitQuery, - variables: variables.isEmpty ? nil : variables, - responseType: RepositoriesResponse.self, - cacheKey: cacheKey(for: service) - ) - return result.repositories ?? Self.emptyPage } + let result = try await client.executeAndCache( + service: service, + query: Self.gitQuery, + variables: variables.isEmpty ? nil : variables, + responseType: RepositoriesResponse.self, + cacheKey: cacheKey(for: service) + ) + return result.repositories ?? Self.emptyPage } else { - switch service { - case .git: - let result = try await client.execute( - service: service, - query: Self.gitQuery, - variables: variables.isEmpty ? nil : variables, - responseType: RepositoriesResponse.self - ) - return result.repositories ?? Self.emptyPage - case .hg: + if service == .hg { let hgVariables = cursor.map { ["cursor": $0 as any Sendable] } let result = try await client.execute( service: service, @@ -540,15 +524,14 @@ final class RepositoryListViewModel { } ?? [], cursor: result.repositories?.cursor ) - default: - let result = try await client.execute( - service: service, - query: Self.gitQuery, - variables: variables.isEmpty ? nil : variables, - responseType: RepositoriesResponse.self - ) - return result.repositories ?? Self.emptyPage } + let result = try await client.execute( + service: service, + query: Self.gitQuery, + variables: variables.isEmpty ? nil : variables, + responseType: RepositoriesResponse.self + ) + return result.repositories ?? Self.emptyPage } } diff --git a/Hutch/Views/Repositories/RepositoryRowView.swift b/Hutch/Views/Repositories/RepositoryRowView.swift index a2d120b..86c8889 100644 --- a/Hutch/Views/Repositories/RepositoryRowView.swift +++ b/Hutch/Views/Repositories/RepositoryRowView.swift @@ -154,17 +154,17 @@ struct VisibilityBadge: View { private var label: String { switch visibility { - case .public: "PUBLIC" + case .publicVisibility: "PUBLIC" case .unlisted: "UNLISTED" - case .private: "PRIVATE" + case .privateVisibility: "PRIVATE" } } private var color: Color { switch visibility { - case .public: .green + case .publicVisibility: .green case .unlisted: .orange - case .private: .red + case .privateVisibility: .red } } } diff --git a/Hutch/Views/Repositories/RepositorySettingsView.swift b/Hutch/Views/Repositories/RepositorySettingsView.swift index 44b50ae..9f172a8 100644 --- a/Hutch/Views/Repositories/RepositorySettingsView.swift +++ b/Hutch/Views/Repositories/RepositorySettingsView.swift @@ -227,9 +227,9 @@ struct RepositorySettingsView: View { private func visibilitySection(_ viewModel: RepositorySettingsViewModel) -> some View { Section { Picker("Visibility", selection: Bindable(viewModel).editedVisibility) { - Text("Public").tag(Visibility.public) + Text("Public").tag(Visibility.publicVisibility) Text("Unlisted").tag(Visibility.unlisted) - Text("Private").tag(Visibility.private) + Text("Private").tag(Visibility.privateVisibility) } .themedRow() @@ -283,11 +283,11 @@ struct RepositorySettingsView: View { private func visibilityConfirmationMessage(for viewModel: RepositorySettingsViewModel) -> String { switch viewModel.editedVisibility { - case .public: + case .publicVisibility: "Anyone will be able to find and view this repository." case .unlisted: "People with the link can view this repository, but it won't appear in public listings." - case .private: + case .privateVisibility: "Only people with explicit access will be able to view this repository." } } diff --git a/Hutch/Views/Repositories/RepositorySettingsViewModel.swift b/Hutch/Views/Repositories/RepositorySettingsViewModel.swift index 8bd80a1..6233bec 100644 --- a/Hutch/Views/Repositories/RepositorySettingsViewModel.swift +++ b/Hutch/Views/Repositories/RepositorySettingsViewModel.swift @@ -20,15 +20,17 @@ private struct UpdatedRepositoryPayload: Decodable, Sendable { func repositorySummary(using owner: Entity, service: SRHTService) -> RepositorySummary { RepositorySummary( - id: id, - rid: rid, - service: service, - name: name, - description: description, - visibility: visibility, - updated: updated, - owner: owner, - head: head + fields: .init( + id: id, + rid: rid, + service: service, + name: name, + description: description, + visibility: visibility, + updated: updated, + owner: owner, + head: head + ) ) } } diff --git a/Hutch/Views/Repositories/RepositorySummarySupport.swift b/Hutch/Views/Repositories/RepositorySummarySupport.swift index 741ff39..393e3ff 100644 --- a/Hutch/Views/Repositories/RepositorySummarySupport.swift +++ b/Hutch/Views/Repositories/RepositorySummarySupport.swift @@ -37,11 +37,11 @@ func repositoryCloneURLs(for repository: RepositorySummary) -> RepositoryCloneUR func repositoryVisibilityLabel(_ visibility: Visibility) -> String { switch visibility { - case .public: + case .publicVisibility: return "Public" case .unlisted: return "Unlisted" - case .private: + case .privateVisibility: return "Private" } } diff --git a/Hutch/Views/Settings/SettingsViewModel.swift b/Hutch/Views/Settings/SettingsViewModel.swift index 29103f6..0b55e6a 100644 --- a/Hutch/Views/Settings/SettingsViewModel.swift +++ b/Hutch/Views/Settings/SettingsViewModel.swift @@ -228,10 +228,12 @@ final class SettingsViewModel { service: .meta, query: Self.updateUserMutation, variables: ["input": input], - fileVariablePath: "input.avatar", - fileData: jpegData, - fileName: "avatar.jpg", - mimeType: "image/jpeg", + file: MultipartUploadFile( + variablePath: "input.avatar", + fileData: jpegData, + fileName: "avatar.jpg", + mimeType: "image/jpeg" + ), responseType: UpdateUserResponse.self ) let updated = result.updateUser diff --git a/Hutch/Views/Tickets/TicketListView.swift b/Hutch/Views/Tickets/TicketListView.swift index 940a282..afee96d 100644 --- a/Hutch/Views/Tickets/TicketListView.swift +++ b/Hutch/Views/Tickets/TicketListView.swift @@ -1400,11 +1400,13 @@ struct FlowLayout: Layout { var spacing: CGFloat = 4 func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize { + _ = cache let result = layoutSubviews(proposal: proposal, subviews: subviews) return result.size } func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) { + _ = cache let result = layoutSubviews(proposal: proposal, subviews: subviews) for (index, position) in result.positions.enumerated() { subviews[index].place( diff --git a/Hutch/Views/Tickets/TrackerListView.swift b/Hutch/Views/Tickets/TrackerListView.swift index 9ca3340..5deb513 100644 --- a/Hutch/Views/Tickets/TrackerListView.swift +++ b/Hutch/Views/Tickets/TrackerListView.swift @@ -37,7 +37,7 @@ struct TrackerListView: View { error: viewModel.error, initialName: "", initialDescription: "", - initialVisibility: .public + initialVisibility: .publicVisibility ) { name, description, visibility in if let tracker = await viewModel.createTracker( name: name, diff --git a/Hutch/Views/Tickets/TrackerManagementView.swift b/Hutch/Views/Tickets/TrackerManagementView.swift index 4e04bbd..fad1ae8 100644 --- a/Hutch/Views/Tickets/TrackerManagementView.swift +++ b/Hutch/Views/Tickets/TrackerManagementView.swift @@ -659,9 +659,9 @@ struct TrackerEditorSheet: View { .lineLimit(2...4) .themedRow() Picker("Visibility", selection: $visibility) { - Text("Public").tag(Visibility.public) + Text("Public").tag(Visibility.publicVisibility) Text("Unlisted").tag(Visibility.unlisted) - Text("Private").tag(Visibility.private) + Text("Private").tag(Visibility.privateVisibility) } .themedRow() } |
