-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
DRYCode duplication / DRY violationCode duplication / DRY violationtech-debtTechnical debt and code quality improvementsTechnical debt and code quality improvements
Description
Context
MCSConfig, PackRegistryFile, ProjectIndex, and Lockfile all implement the same YAML persistence boilerplate:
Load: guard empty → String(contentsOf:) → YAMLDecoder().decode()
Save: mkdir → YAMLEncoder().encode() → write(to:atomically:)
Each has small nuances (MCSConfig swallows errors, others throw), but the structural pattern is identical.
Proposed Change
Extract a generic helper, e.g.:
enum YAMLFile {
static func load<T: Decodable>(_ type: T.Type, from path: URL) throws -> T?
static func save<T: Encodable>(_ value: T, to path: URL) throws
}Each caller can wrap this with its own error-handling policy (swallow vs throw).
Files to Modify
Sources/mcs/Core/MCSConfig.swiftSources/mcs/ExternalPack/PackRegistryFile.swiftSources/mcs/Core/ProjectIndex.swiftSources/mcs/Core/Lockfile.swift
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
DRYCode duplication / DRY violationCode duplication / DRY violationtech-debtTechnical debt and code quality improvementsTechnical debt and code quality improvements