Skip to content

Commit 0f78251

Browse files
committed
chore(swift): fix SwiftFormat violations in CI
SwiftFormat fixes: - Wrap single-line property bodies onto multiple lines (wrapPropertyBodies) - Remove redundant property definitions (redundantProperty) - Convert regular comments to doc comments for API declarations (docComments) All violations from CI build resolved. 28/73 files formatted.
1 parent 8911477 commit 0f78251

28 files changed

+181
-186
lines changed

swift-gui/ARMEmulator/ARMEmulatorApp.swift

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
import SwiftUI
22

3-
// Environment key for accessing AppDelegate
4-
private struct AppDelegateKey: EnvironmentKey {
5-
static let defaultValue: AppDelegate? = nil
6-
}
7-
83
extension EnvironmentValues {
9-
var appDelegate: AppDelegate? {
10-
get { self[AppDelegateKey.self] }
11-
set { self[AppDelegateKey.self] = newValue }
12-
}
4+
@Entry var appDelegate: AppDelegate?
135
}
146

157
@MainActor
@@ -19,7 +11,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
1911
let settings = AppSettings.shared
2012
weak var viewModel: EmulatorViewModel?
2113

22-
// Startup file path from command-line arguments (parsed once on first access)
14+
/// Startup file path from command-line arguments (parsed once on first access)
2315
private(set) lazy var startupFilePath: String? = {
2416
let args = CommandLine.arguments
2517

swift-gui/ARMEmulator/Models/ProgramState.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,14 @@ struct DisassemblyInstruction: Codable, Identifiable, Hashable {
4242
var disassembly: String
4343
var symbol: String?
4444

45-
var id: UInt32 { address }
45+
var id: UInt32 {
46+
address
47+
}
4648

47-
// Alias for compatibility with code expecting 'mnemonic'
48-
var mnemonic: String { disassembly }
49+
/// Alias for compatibility with code expecting 'mnemonic'
50+
var mnemonic: String {
51+
disassembly
52+
}
4953

5054
func hash(into hasher: inout Hasher) {
5155
hasher.combine(address)

swift-gui/ARMEmulator/Services/APIClient.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,7 @@ class APIClient: APIClientProtocol, @unchecked Sendable {
209209
}
210210

211211
let url = baseURL.appendingPathComponent("/api/v1/session/\(sessionID)/watchpoint")
212-
let watchpoint: Watchpoint = try await post(url: url, body: WatchpointRequest(address: address, type: type))
213-
return watchpoint
212+
return try await post(url: url, body: WatchpointRequest(address: address, type: type))
214213
}
215214

216215
func removeWatchpoint(sessionID: String, watchpointID: Int) async throws {

swift-gui/ARMEmulator/ViewModels/EmulatorViewModel.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class EmulatorViewModel: ObservableObject {
2525
@Published var errorMessage: String?
2626
@Published var isConnected = false
2727

28-
// Callback for scrolling editor to current PC
28+
/// Callback for scrolling editor to current PC
2929
var scrollToCurrentPC: (() -> Void)?
3030

3131
// Memory state
@@ -34,16 +34,16 @@ class EmulatorViewModel: ObservableObject {
3434
@Published var lastMemoryWrite: UInt32?
3535
@Published var lastMemoryWriteSize: UInt32 = 4 // Size in bytes (1, 2, or 4)
3636

37-
// Disassembly state
37+
/// Disassembly state
3838
@Published var disassembly: [DisassemblyInstruction] = []
3939

40-
// Source map: address -> source line (for display)
40+
/// Source map: address -> source line (for display)
4141
@Published var sourceMap: [UInt32: String] = [:]
42-
// Valid breakpoint lines (1-based line numbers that can have breakpoints)
42+
/// Valid breakpoint lines (1-based line numbers that can have breakpoints)
4343
@Published var validBreakpointLines: Set<Int> = []
44-
// Line number to address mapping for breakpoint setting
44+
/// Line number to address mapping for breakpoint setting
4545
@Published var lineToAddress: [Int: UInt32] = [:]
46-
// Address to line number mapping for breakpoint display
46+
/// Address to line number mapping for breakpoint display
4747
@Published var addressToLine: [UInt32: Int] = [:]
4848

4949
let apiClient: any APIClientProtocol
@@ -52,12 +52,12 @@ class EmulatorViewModel: ObservableObject {
5252
private var cancellables = Set<AnyCancellable>()
5353
private var isInitializing = false
5454

55-
// Computed property: determines if pause button should be enabled
55+
/// Computed property: determines if pause button should be enabled
5656
var canPause: Bool {
5757
status == .running || status == .waitingForInput
5858
}
5959

60-
// Computed property: determines if step buttons should be enabled
60+
/// Computed property: determines if step buttons should be enabled
6161
var canStep: Bool {
6262
status == .idle || status == .breakpoint
6363
}

swift-gui/ARMEmulator/Views/AboutView.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ struct AboutView: View {
77
@State private var errorMessage: String?
88
private let apiClient = APIClient()
99

10-
// Cache version info to avoid repeated API calls
10+
/// Cache version info to avoid repeated API calls
1111
private static var cachedVersion: BackendVersion?
1212

1313
var body: some View {
@@ -80,7 +80,8 @@ struct AboutView: View {
8080
}
8181
}
8282

83-
private func loadVersionAsync() async { isLoading = true
83+
private func loadVersionAsync() async {
84+
isLoading = true
8485
errorMessage = nil
8586

8687
do {

swift-gui/ARMEmulator/Views/CustomGutterView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class CustomGutterView: NSView {
4444
fatalError("init(coder:) not implemented")
4545
}
4646

47-
// Use flipped coordinates (origin at top-left) to match text view
47+
/// Use flipped coordinates (origin at top-left) to match text view
4848
override var isFlipped: Bool {
4949
true
5050
}

swift-gui/ARMEmulator/Views/EditorView.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ struct EditorView: View {
99
@State private var scrollView: NSScrollView?
1010
@EnvironmentObject var viewModel: EmulatorViewModel
1111

12-
// Compute editor editability based on VM state
13-
// Editor is editable only when VM is completely stopped (idle, halted, error)
14-
// Editor is read-only during any form of execution (running, paused, breakpoint, waitingForInput)
12+
/// Compute editor editability based on VM state
13+
/// Editor is editable only when VM is completely stopped (idle, halted, error)
14+
/// Editor is read-only during any form of execution (running, paused, breakpoint, waitingForInput)
1515
private var isEditable: Bool {
1616
viewModel.status == .idle || viewModel.status == .halted || viewModel.status == .error
1717
}
@@ -173,7 +173,7 @@ struct EditorView: View {
173173
}
174174
}
175175

176-
// Custom text view wrapper for editor
176+
/// Custom text view wrapper for editor
177177
struct EditorWithGutterView: NSViewRepresentable {
178178
@Binding var text: String
179179
@Binding var breakpoints: Set<Int>

swift-gui/ARMEmulator/Views/ExpressionEvaluatorView.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ struct ExpressionEvaluatorView: View {
8484
.navigationTitle("Expression Evaluator")
8585
}
8686

87-
@ViewBuilder
8887
private func resultRow(_ result: EvaluationResult) -> some View {
8988
VStack(alignment: .leading, spacing: 4) {
9089
HStack {
@@ -114,7 +113,6 @@ struct ExpressionEvaluatorView: View {
114113
.cornerRadius(8)
115114
}
116115

117-
@ViewBuilder
118116
private func resultValue(label: String, value: String) -> some View {
119117
VStack(alignment: .leading, spacing: 2) {
120118
Text(label)

swift-gui/ARMEmulator/Views/FileCommands.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ struct FileCommands: Commands {
7575
}
7676
}
7777

78-
// Notification for showing examples browser
78+
/// Notification for showing examples browser
7979
extension Notification.Name {
8080
static let showExamplesBrowser = Notification.Name("showExamplesBrowser")
8181
}
8282

83-
// FocusedValue key for accessing ViewModel from commands
83+
/// FocusedValue key for accessing ViewModel from commands
8484
struct ViewModelKey: FocusedValueKey {
8585
typealias Value = EmulatorViewModel
8686
}

swift-gui/ARMEmulator/Views/MemoryView.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ struct MemoryView: View {
1212

1313
private let bytesPerRow = 16
1414
private let rowsToShow = 16
15-
private var totalBytes: Int { bytesPerRow * rowsToShow }
15+
private var totalBytes: Int {
16+
bytesPerRow * rowsToShow
17+
}
1618

1719
var body: some View {
1820
VStack(spacing: 0) {

0 commit comments

Comments
 (0)