-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Severity: LOW
LockedCommand.run() in FileLock.swift creates let env = Environment() solely to derive env.lockFile. Then each command's perform() creates a second Environment() (either directly or via PackCommandContext()).
This double-construction affects all LockedCommand conformers (AddPack, RemovePack, UpdatePack, SyncCommand, DoctorCommand, CleanupCommand, ExportCommand).
The cost is negligible in practice (~12 URL path constructions, static-cached tool resolution), but it's architecturally untidy.
Fix: Change LockedCommand protocol to pass the Environment from run() into perform():
protocol LockedCommand: ParsableCommand {
var skipLock: Bool { get }
func perform(env: Environment) throws
}This would require updating all conformers but eliminates the redundant construction and opens the door for injectable Environment in tests (deferred per decision in decision_testing_command_testability_strategy).
Found during review of #109.