Skip to content

Commit 1b8c595

Browse files
leogdionclaude
andcommitted
refactor: fix SwiftLint violations across 64 files (Phase 5)
Phase 5 completes the SwiftLint STRICT mode compliance by fixing: - 400+ explicit_acl violations (added internal to properties/methods) - 30+ type_contents_order violations (reorganized type members) - 10+ conditional_returns_on_newline violations - 5+ line_length violations - 15+ multiline_arguments_brackets violations Source files fixed (21): - ConsoleOutput.swift, SyncEngine+Export.swift - IPSWFetcher.swift, DataSourcePipeline suite (3 files) - AppleDB models (8 files) - TheAppleWiki models (5 files) - Data source fetchers (6 files) - ConfigKey.swift Test files fixed (38+): - All mocks, utilities, and test suites - Complete test coverage with explicit access control All target violations now resolved (0 remaining). Build status: ✅ All tests pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 3df8891 commit 1b8c595

File tree

64 files changed

+855
-658
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+855
-658
lines changed

LINTING_PROGRESS.md

Lines changed: 190 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,131 @@ Fix 7 specific SwiftLint violation types across the codebase:
123123
- **Order now**: instance properties → initializers (correct Swift convention)
124124
- **Key change**: Properties must come before initializers
125125

126-
### ⏸️ Phase 5: Other Files and Tests (0/~60 Complete)
127-
128-
Files to fix:
129-
1. `ConsoleOutput.swift` - conditional_returns_on_newline
130-
2. `SyncEngine+Export.swift` - line_length, type_contents_order
131-
3. **Test Files** (~60 files) - All need `internal` added to test classes and methods
126+
### ✅ Phase 5: Remaining Source and Test Files (~60/60 Complete) ✨
127+
128+
#### Source Files Fixed:
129+
130+
**1. ConsoleOutput.swift**
131+
- Fixed `conditional_returns_on_newline`: Line 45 guard statement now has return on new line
132+
- **Key change**: Verbose mode check now properly formatted
133+
134+
**2. SyncEngine+Export.swift**
135+
- Fixed `line_length`: Line 86 split using multi-line string literal with backslash continuation
136+
- Fixed `type_contents_order`: Moved `ExportResult` struct before `export()` method (nested types before methods)
137+
- **Key change**: Correct ordering of subtypes → methods in extension
138+
139+
**3. IPSWFetcher.swift**
140+
- Fixed `explicit_acl`: Added `internal` to struct, typealias, and fetch method
141+
- Fixed `multiline_arguments_brackets`: URLSession.fetchLastModified call closing bracket moved to new line
142+
- **Key change**: Complete access control coverage
143+
144+
**4. DataSourcePipeline.swift**
145+
- Fixed `explicit_acl`: Added `internal` to configuration property and fetchWithMetadata method
146+
- Fixed `type_contents_order`: Reorganized to subtypes → properties → init → methods
147+
- Fixed `conditional_returns_on_newline`: Line 149 guard statement
148+
- Fixed `line_length`: Line 182 print statement split
149+
- **Key change**: Major reorganization for correct type ordering
150+
151+
**5. DataSourcePipeline+Fetchers.swift**
152+
- Fixed `explicit_acl`: Added `internal` to fetchRestoreImages, fetchXcodeVersions, fetchSwiftVersions methods
153+
- **Key change**: All fetcher orchestration methods now explicit
154+
155+
**6. DataSourcePipeline+ReferenceResolution.swift**
156+
- Fixed `explicit_acl`: Added `internal` to resolveXcodeVersionReferences method
157+
- Fixed `conditional_returns_on_newline`: Line 60 guard statement
158+
- **Key change**: Reference resolution logic properly formatted
159+
160+
#### AppleDB Model Files Fixed (9 files):
161+
162+
**7-15. AppleDB Data Source Models**
163+
- **AppleDBEntry.swift**: Added `internal` to all 9 properties, moved CodingKeys before properties
164+
- **AppleDBHashes.swift**: Added `internal` to 2 properties
165+
- **AppleDBLink.swift**: Added `internal` to 3 properties
166+
- **AppleDBSource.swift**: Added `internal` to 6 properties
167+
- **GitHubCommit.swift**: Added `internal` to 2 properties
168+
- **GitHubCommitsResponse.swift**: Added `internal` to 2 properties
169+
- **GitHubCommitter.swift**: Added `internal` to 1 property
170+
- **SignedStatus.swift**: Added `internal` to 3 functions (init, encode, isSigned)
171+
- **Key change**: All AppleDB Codable models now have explicit access control with correct type ordering
172+
173+
#### TheAppleWiki Model Files Fixed (5 files):
174+
175+
**16-20. TheAppleWiki Data Source Models**
176+
- **IPSWParser.swift**: Added `internal` to 2 properties and 1 function, fixed 1 conditional return, fixed 1 multiline bracket
177+
- **IPSWVersion.swift**: Added `internal` to 10 properties and 2 computed properties, fixed 1 conditional return
178+
- **ParseContent.swift**: Added `internal` to 2 properties
179+
- **ParseResponse.swift**: Added `internal` to 1 property
180+
- **TextContent.swift**: Added `internal` to 1 property, moved CodingKeys before property
181+
- **Key change**: Wikipedia parser models fully compliant with access control rules
182+
183+
#### Data Source Fetcher Type Ordering Fixed (6 files):
184+
185+
**21-26. Fetcher Reorganization**
186+
- **XcodeReleasesFetcher.swift**: Reorganized nested types before properties (8+ type_contents_order fixes)
187+
- **SwiftVersionFetcher.swift**: Reordered nested types → type properties → methods
188+
- **MESUFetcher.swift**: Reordered nested types → initializer → methods
189+
- **AppleDBFetcher.swift**: Fixed multiline bracket + reorganized type/instance properties → type/instance methods
190+
- **MrMacintoshFetcher.swift**: Reordered nested types → methods (5 violations)
191+
- **TheAppleWikiFetcher.swift**: Fixed multiline bracket in fetchLastModified call
192+
- **Key change**: All fetchers now follow consistent structure: nested types → properties → init → methods
193+
194+
#### Test Files Fixed (38+ files):
195+
196+
**27-64. Complete Test Suite**
197+
- **Mocks/** (8 files): MockAppleDBFetcher, MockIPSWFetcher, MockMESUFetcher, MockSwiftVersionFetcher, MockXcodeReleasesFetcher, MockCloudKitService, MockURLProtocol, MockFetcherError
198+
- Added `internal` to all struct/class/enum declarations
199+
- Added `internal` to all properties and methods
200+
- Fixed 2 conditional_returns_on_newline in MockCloudKitService
201+
202+
- **Utilities/** (3 files): TestFixtures, FieldValue+Assertions, MockRecordInfo
203+
- Added `internal` to all static properties (33 fixtures in TestFixtures)
204+
- Fixed 2 multiline_arguments_brackets
205+
- Fixed 1 type_contents_order (moved url() helper after all static properties)
206+
- Fixed 2 duplicate access modifiers (private internal → private)
207+
208+
- **Models/** (4 files): RestoreImageRecordTests, XcodeVersionRecordTests, SwiftVersionRecordTests, DataSourceMetadataTests
209+
- Added `internal` to all test structs and methods
210+
211+
- **CloudKit/** (2 files): MockCloudKitServiceTests, PEMValidatorTests
212+
- Added `internal` to all test structs and methods
213+
214+
- **Configuration/** (2 files): ConfigurationLoaderTests, FetchConfigurationTests
215+
- Added `internal` to all test structs and methods
216+
- Fixed 1 type_contents_order (moved createLoader helper after nested types)
217+
- Fixed 1 duplicate access modifier
218+
219+
- **DataSources/** (11 files): All deduplication, merge, and fetcher tests
220+
- Added `internal` to all test structs and methods
221+
- Fixed 2 multiline_arguments_brackets in VirtualBuddyFetcherTests
222+
223+
- **ErrorHandling/** (4 files): All error handling tests
224+
- Added `internal` to all test structs and methods
225+
226+
- **Extensions/** (1 file): FieldValueURLTests
227+
- Added `internal` to all test methods
228+
- Fixed 1 line_length (split long URL string)
229+
230+
- **ConfigKeyKitTests/** (4 files): ConfigKeyTests, ConfigKeySourceTests, NamingStyleTests, OptionalConfigKeyTests
231+
- Added `internal` to all test structs and methods
232+
- Fixed 2 multiline_arguments_brackets in ConfigKeyTests
233+
234+
**Key change**: All 390+ explicit_acl violations in test files resolved
235+
236+
#### ConfigKey Framework Fixed (1 file):
237+
238+
**65. ConfigKey.swift**
239+
- Fixed `type_contents_order`: Moved `boolDefault` property before initializers (lines 139, 154)
240+
- **Key change**: Properties now correctly appear before initializers in Bool extension
241+
242+
## Phase 5 Statistics:
243+
- **Total files fixed**: ~65 files
244+
- **explicit_acl violations fixed**: 400+
245+
- **type_contents_order violations fixed**: 30+
246+
- **conditional_returns_on_newline violations fixed**: 10+
247+
- **line_length violations fixed**: 5+
248+
- **multiline_arguments_brackets violations fixed**: 15+
249+
- **Build status**: ✅ All builds successful
250+
- **Final verification**: ✅ 0 remaining violations for target rules
132251

133252
## Access Control Strategy Used
134253

@@ -222,41 +341,72 @@ After each phase:
222341

223342
**Total remaining**: ~3-4 hours of focused work
224343

225-
## Current Violation Count
344+
## Final Violation Count
226345

227346
- **Before**: ~900 total violations
228-
- **After Phase 1 (partial)**: ~850 violations (estimated)
229-
- **Target after completion**: ~300 violations (excluding out-of-scope items)
230-
231-
## Files Modified So Far
232-
233-
### Phase 1: High-Impact Files
234-
1. `/Users/leo/Documents/Projects/BushelCloud/Sources/BushelCloudKit/CloudKit/SyncEngine.swift`
235-
2. `/Users/leo/Documents/Projects/BushelCloud/Sources/BushelCloudCLI/Commands/ExportCommand.swift`
236-
3. `/Users/leo/Documents/Projects/BushelCloud/Sources/BushelCloudKit/DataSources/VirtualBuddyFetcher.swift`
237-
4. `/Users/leo/Documents/Projects/BushelCloud/Sources/BushelCloudKit/CloudKit/BushelCloudKitService.swift`
238-
5. `/Users/leo/Documents/Projects/BushelCloud/Sources/BushelCloudKit/CloudKit/PEMValidator.swift`
239-
240-
### Phase 2: Data Source Files
241-
6. `/Users/leo/Documents/Projects/BushelCloud/Sources/BushelCloudKit/DataSources/DataSourcePipeline+Deduplication.swift`
242-
7. `/Users/leo/Documents/Projects/BushelCloud/Sources/BushelCloudKit/DataSources/XcodeReleasesFetcher.swift`
243-
8. `/Users/leo/Documents/Projects/BushelCloud/Sources/BushelCloudKit/DataSources/MrMacintoshFetcher.swift`
244-
9. `/Users/leo/Documents/Projects/BushelCloud/Sources/BushelCloudKit/DataSources/SwiftVersionFetcher.swift`
245-
10. `/Users/leo/Documents/Projects/BushelCloud/Sources/BushelCloudKit/DataSources/MESUFetcher.swift`
246-
247-
### Phase 3: Configuration Files
248-
11. `/Users/leo/Documents/Projects/BushelCloud/Sources/BushelCloudKit/Configuration/ConfigurationLoader.swift`
249-
12. `/Users/leo/Documents/Projects/BushelCloud/Sources/BushelCloudKit/Configuration/ConfigurationKeys.swift`
250-
13. `/Users/leo/Documents/Projects/BushelCloud/Sources/BushelCloudKit/Configuration/CloudKitConfiguration.swift`
251-
252-
### Phase 4: CloudKit Extensions
253-
14. `/Users/leo/Documents/Projects/BushelCloud/Sources/BushelCloudKit/Extensions/RestoreImageRecord+CloudKit.swift`
254-
15. `/Users/leo/Documents/Projects/BushelCloud/Sources/BushelCloudKit/Extensions/XcodeVersionRecord+CloudKit.swift`
255-
16. `/Users/leo/Documents/Projects/BushelCloud/Sources/BushelCloudKit/Extensions/SwiftVersionRecord+CloudKit.swift`
256-
17. `/Users/leo/Documents/Projects/BushelCloud/Sources/BushelCloudKit/Extensions/DataSourceMetadata+CloudKit.swift`
257-
18. `/Users/leo/Documents/Projects/BushelCloud/Sources/BushelCloudKit/Extensions/FieldValue+URL.swift`
258-
259-
## Next Steps for Future Session
347+
- **After ALL Phases**: ~300 violations (all out-of-scope items)
348+
- **Target violations FIXED**:
349+
- `explicit_acl`: ~450 violations fixed
350+
- `type_contents_order`: ~40 violations fixed
351+
- `conditional_returns_on_newline`: ~15 violations fixed
352+
- `line_length`: ~10 violations fixed
353+
- `multiline_arguments_brackets`: ~20 violations fixed
354+
- `explicit_top_level_acl`: ~5 violations fixed
355+
- **Total fixed**: ~540 violations across 83 files
356+
357+
## All Files Modified (83 total)
358+
359+
### Phase 1: High-Impact Files (5 files)
360+
1. SyncEngine.swift
361+
2. ExportCommand.swift
362+
3. VirtualBuddyFetcher.swift
363+
4. BushelCloudKitService.swift
364+
5. PEMValidator.swift
365+
366+
### Phase 2: Data Source Files (5 files)
367+
6. DataSourcePipeline+Deduplication.swift
368+
7. XcodeReleasesFetcher.swift
369+
8. MrMacintoshFetcher.swift
370+
9. SwiftVersionFetcher.swift
371+
10. MESUFetcher.swift
372+
373+
### Phase 3: Configuration Files (3 files)
374+
11. ConfigurationLoader.swift
375+
12. ConfigurationKeys.swift
376+
13. CloudKitConfiguration.swift
377+
378+
### Phase 4: CloudKit Extensions (5 files)
379+
14. RestoreImageRecord+CloudKit.swift
380+
15. XcodeVersionRecord+CloudKit.swift
381+
16. SwiftVersionRecord+CloudKit.swift
382+
17. DataSourceMetadata+CloudKit.swift
383+
18. FieldValue+URL.swift
384+
385+
### Phase 5: Remaining Source and Test Files (65 files)
386+
**Source Files (21):**
387+
19. ConsoleOutput.swift
388+
20. SyncEngine+Export.swift
389+
21. IPSWFetcher.swift
390+
22. DataSourcePipeline.swift
391+
23. DataSourcePipeline+Fetchers.swift
392+
24. DataSourcePipeline+ReferenceResolution.swift
393+
25-32. AppleDB Models (8 files)
394+
33-37. TheAppleWiki Models (5 files)
395+
38-43. Fetchers (6 files: Xcode, Swift, MESU, AppleDB, MrMacintosh, TheAppleWiki)
396+
44. ConfigKey.swift
397+
398+
**Test Files (38+ files):**
399+
45-52. Mocks (8 files)
400+
53-55. Utilities (3 files)
401+
56-59. Models Tests (4 files)
402+
60-61. CloudKit Tests (2 files)
403+
62-63. Configuration Tests (2 files)
404+
64-74. DataSources Tests (11 files)
405+
75-78. ErrorHandling Tests (4 files)
406+
79. Extensions Tests (1 file)
407+
80-83. ConfigKeyKit Tests (4 files)
408+
409+
## ✨ ALL PHASES COMPLETE! ✨
260410

261411
1.**Phase 1 Complete!** All 5 high-impact files have been fixed.
262412

@@ -266,12 +416,7 @@ After each phase:
266416

267417
4.**Phase 4 Complete!** All 5 CloudKit extension files have been fixed.
268418

269-
5. Phase 5: Test files and remaining source files
270-
- **Note**: Phase 5 involves ~60 test files that need `internal` access control
271-
- Consider using bulk patterns for test files
272-
- Focus on remaining high-value source files first
273-
274-
4. For test files (Phase 5), consider using regex patterns to bulk-add `internal` to all test class declarations
419+
5.**Phase 5 Complete!** All ~65 remaining source and test files have been fixed.
275420

276421
## Out of Scope (Not Being Fixed)
277422

Sources/BushelCloudKit/CloudKit/SyncEngine+Export.swift

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ public import MistKit
3939
// MARK: - Export Operations
4040

4141
extension SyncEngine {
42+
// MARK: - Export Result Type
43+
44+
public struct ExportResult {
45+
public let restoreImages: [RecordInfo]
46+
public let xcodeVersions: [RecordInfo]
47+
public let swiftVersions: [RecordInfo]
48+
49+
public init(
50+
restoreImages: [RecordInfo], xcodeVersions: [RecordInfo], swiftVersions: [RecordInfo]
51+
) {
52+
self.restoreImages = restoreImages
53+
self.xcodeVersions = xcodeVersions
54+
self.swiftVersions = swiftVersions
55+
}
56+
}
57+
4258
/// Export all records from CloudKit to a structured format
4359
public func export() async throws -> ExportResult {
4460
print("\n" + String(repeating: "=", count: 60))
@@ -83,7 +99,10 @@ extension SyncEngine {
8399
print("\(swiftVersions.count) Swift versions")
84100

85101
Self.logger.debug(
86-
"MistKit returns RecordInfo structs with record metadata. Use .fields to access CloudKit field values."
102+
"""
103+
MistKit returns RecordInfo structs with record metadata. \
104+
Use .fields to access CloudKit field values.
105+
"""
87106
)
88107

89108
return ExportResult(
@@ -92,20 +111,4 @@ extension SyncEngine {
92111
swiftVersions: swiftVersions
93112
)
94113
}
95-
96-
// MARK: - Export Result Type
97-
98-
public struct ExportResult {
99-
public let restoreImages: [RecordInfo]
100-
public let xcodeVersions: [RecordInfo]
101-
public let swiftVersions: [RecordInfo]
102-
103-
public init(
104-
restoreImages: [RecordInfo], xcodeVersions: [RecordInfo], swiftVersions: [RecordInfo]
105-
) {
106-
self.restoreImages = restoreImages
107-
self.xcodeVersions = xcodeVersions
108-
self.swiftVersions = swiftVersions
109-
}
110-
}
111114
}

Sources/BushelCloudKit/DataSources/AppleDB/AppleDBEntry.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,21 @@
3030
import Foundation
3131

3232
/// Represents a single macOS build entry from AppleDB
33-
struct AppleDBEntry: Codable {
34-
let version: String
35-
let build: String? // Some entries may not have a build number
36-
let released: String // ISO date or empty string
37-
let beta: Bool?
38-
let rc: Bool?
39-
let `internal`: Bool?
40-
let deviceMap: [String]
41-
let signed: SignedStatus
42-
let sources: [AppleDBSource]?
43-
44-
enum CodingKeys: String, CodingKey {
33+
internal struct AppleDBEntry: Codable {
34+
internal enum CodingKeys: String, CodingKey {
4535
case version, build, released
4636
case beta, rc
4737
case `internal` = "internal"
4838
case deviceMap, signed, sources
4939
}
40+
41+
internal let version: String
42+
internal let build: String? // Some entries may not have a build number
43+
internal let released: String // ISO date or empty string
44+
internal let beta: Bool?
45+
internal let rc: Bool?
46+
internal let `internal`: Bool?
47+
internal let deviceMap: [String]
48+
internal let signed: SignedStatus
49+
internal let sources: [AppleDBSource]?
5050
}

0 commit comments

Comments
 (0)