Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Cut the comments that only repeat what the code says

Țugui Dragoșa22b45160f26
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift
index ee8aa435..99efa4b0 100644
--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift
+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift
@@ -307,7 +307,6 @@ struct UninstallCommand: AsyncParsableCommand {
let needsReview: Int
let leftForAnAdministrator: Int
let unreadableLocations: [String]
- /// The lines of the shell startup files that still name what moved.
let shellReferences: [ShellReference]
struct ShellReference: Encodable {
@@ -850,8 +849,6 @@ struct UpdatesCommand: AsyncParsableCommand {
}
}
- /// Says why the apps these casks installed got no answer: Homebrew's last check for new versions is too old to
- /// tell (`UpdateChecker.caskNotCheckedRecently`).
static func note(aboutCasksNotCheckedRecently casks: [HomebrewPackage], timeZone: TimeZone = .current) -> String? {
guard !casks.isEmpty else { return nil }
let apps = "\(Output.count(casks.count, "app", "apps")) it installed \(casks.count == 1 ? "is" : "are")"
diff --git a/Packages/PeelCore/Sources/PeelCore/Apps/AppInspector.swift b/Packages/PeelCore/Sources/PeelCore/Apps/AppInspector.swift
index 3b0a0fb2..c875baec 100644
--- a/Packages/PeelCore/Sources/PeelCore/Apps/AppInspector.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Apps/AppInspector.swift
@@ -193,9 +193,8 @@ public enum AppInspector {
}
}
- /// The icon of the app at `url`, as macOS draws it when Launch Services knows the app at that place. Asking
- /// IconServices registers a bundle, as asking for its name does, so any other app's icon comes from its own
- /// files, or is the generic one.
+ /// The icon of the app at `url`. Asking IconServices registers a bundle, as asking its name does, so only an app
+ /// Launch Services knows at that place is asked there; any other's comes from its own files, or is the generic one.
public static func icon(ofAppAt url: URL) -> NSImage {
if bundleIdentifier(ofAppAt: url).map({ isKnown(url, as: $0) }) == true {
return NSWorkspace.shared.icon(forFile: url.path(percentEncoded: false))
@@ -203,7 +202,6 @@ public enum AppInspector {
return ownIcon(ofAppAt: url) ?? NSWorkspace.shared.icon(for: .applicationBundle)
}
- /// The icon in the app's own files: the `.icns` its Info.plist names, else the image its asset catalog holds.
static func ownIcon(ofAppAt url: URL) -> NSImage? {
guard let bundle = Bundle(url: AppBundleLayout(of: url).signedBundle), let info = bundle.infoDictionary else {
return nil
diff --git a/Packages/PeelCore/Sources/PeelCore/Duplicates/DuplicateRemoval.swift b/Packages/PeelCore/Sources/PeelCore/Duplicates/DuplicateRemoval.swift
index 5aa0a3ca..b6352f0a 100644
--- a/Packages/PeelCore/Sources/PeelCore/Duplicates/DuplicateRemoval.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Duplicates/DuplicateRemoval.swift
@@ -1,10 +1,9 @@
public import Foundation
public enum DuplicateRemoval {
- /// Moves the selected folders, then the selected copies, to the Trash as one removal. A copy moves only while
- /// it and at least one unselected copy of its group are unchanged since the scan, and a folder only while it
- /// and an unselected folder of its group still hold exactly what was compared. Each is checked right before its
- /// own move, because a sync client, Finder, or another window can change the kept one while this runs.
+ /// Moves the selected folders, then the selected copies, to the Trash as one removal: each only while it and an
+ /// unselected one of its group are still what the scan compared, checked right before its own move, since a sync
+ /// client, Finder, or another window can change the kept one meanwhile.
@concurrent
public static func trash(
_ selection: Set<URL>,
diff --git a/Packages/PeelCore/Sources/PeelCore/Home/LoginItem.swift b/Packages/PeelCore/Sources/PeelCore/Home/LoginItem.swift
index 9a07d3ca..203bc497 100644
--- a/Packages/PeelCore/Sources/PeelCore/Home/LoginItem.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Home/LoginItem.swift
@@ -1,9 +1,8 @@
import Observation
public import ServiceManagement
-/// Peel's own login item, as macOS reports it, read and changed away from the main actor, since `SMAppService` asks
-/// `smd` over XPC. The switch keeps the value it was set to until macOS answers, and a read that overlaps a change
-/// shows nothing.
+/// Peel's own login item, read and changed away from the main actor, since `SMAppService` asks `smd` over XPC. The
+/// switch keeps the value it was set to until macOS answers, and a read that overlaps a change shows nothing.
@MainActor
@Observable
public final class LoginItem {
diff --git a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
index b9d3239b..cb6f349a 100644
--- a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
@@ -541,9 +541,8 @@ public enum Homebrew {
}
}
- /// When Homebrew last checked for new versions: when `brew update` last touched `.git/FETCH_HEAD` in Homebrew's
- /// repository, the file Homebrew itself compares with `HOMEBREW_AUTO_UPDATE_SECS` before it updates on its own.
- /// Nil when Homebrew doesn't say where its repository is, or the file isn't there.
+ /// When Homebrew last checked for new versions: when `brew update` last touched `.git/FETCH_HEAD` in its
+ /// repository, which Homebrew compares with `HOMEBREW_AUTO_UPDATE_SECS`. Nil when that file can't be found.
@concurrent
public static func lastUpdateCheck() async -> Date? {
guard let answer = try? await answer(["--repository"]), let repository = folder(answering: answer) else {
@@ -864,7 +863,6 @@ public enum Homebrew {
return Set(line.dropFirst(prefix.count).split(separator: ",").map { $0.trimmingCharacters(in: .whitespaces) })
}
- /// The one folder `brew --caskroom` or `brew --repository` answers with.
static func folder(answering answer: String) -> URL? {
let lines = answer.split(whereSeparator: \.isNewline)
guard lines.count == 1, let path = lines.first.map(String.init), path.hasPrefix("/") else { return nil }
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/KeptOnlyHere.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/KeptOnlyHere.swift
index 0bf6c783..c1600495 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/KeptOnlyHere.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/KeptOnlyHere.swift
@@ -30,8 +30,7 @@ enum KeptOnlyHere {
// there, and aren't on its servers. The app's entitlements name this group, where it keeps them.
("Library/Group Containers/group.net.whatsapp.WhatsApp.shared", nil, .holdsMessageHistory),
// 1Password's "Migrate your existing 1Password data from standalone vaults" and "1Password backups":
- // 1Password 7 and earlier kept standalone vaults, and a backup of them each day, in this group, which
- // 1Password 8's signature names too.
+ // 1Password 7 and earlier kept standalone vaults and daily backups in this group, which 1Password 8 claims too.
("Library/Group Containers/2BUA8C4S2C.com.agilebits", nil, .holdsPasswordsOrCodes),
// Strongbox's "Where are Strongbox local backups stored on my Mac".
("Library/Group Containers/group.strongbox.mac.mcguill", "backups", .holdsPasswordsOrCodes),
@@ -55,14 +54,12 @@ enum KeptOnlyHere {
// iTerm2's "Dynamic Profiles" and "Running a Script": the profiles and the scripts the person wrote.
("Library/Application Support/iTerm2", "Scripts", .holdsWorkMadeWithTheApp),
("Library/Application Support/iTerm2", "DynamicProfiles", .holdsWorkMadeWithTheApp),
- // The user profile of LibreOffice and Apache OpenOffice (`UserInstallation` in their sources, `<name>/4` here
- // on a Mac). LibreOffice Help's "Paths": the person's own templates, AutoText, AutoCorrect texts and
- // dictionaries, and the automatic backup copies of documents.
+ // LibreOffice's and Apache OpenOffice's user profile (`UserInstallation`, `<name>/4` on a Mac). LibreOffice
+ // Help's "Paths": the person's templates, AutoText, AutoCorrect texts, dictionaries, and documents' backups.
("Library/Application Support/LibreOffice", nil, .holdsWorkMadeWithTheApp),
("Library/Application Support/OpenOffice", nil, .holdsWorkMadeWithTheApp),
- // Torrent clients keep each torrent added and how far it got apart from what it downloaded, and forget every
- // transfer without them. Transmission's "Configuration Files": `torrents`, `resume` and the Mac app's
- // `Transfers.plist`, in this folder.
+ // Torrent clients keep each torrent and its progress apart from the download, and forget every transfer without
+ // them. Transmission's "Configuration Files": `torrents`, `resume`, and the Mac app's `Transfers.plist`.
("Library/Application Support/Transmission", nil, .holdsTorrents),
// qBittorrent's `SessionImpl`: `BT_backup`, or `torrents.db`, in its data folder.
("Library/Application Support/qBittorrent", "BT_backup", .holdsTorrents),
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/Naming.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/Naming.swift
index d2c12856..e3dfc01a 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/Naming.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/Naming.swift
@@ -79,10 +79,8 @@ enum Identifier {
/// of its own (`DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER`). The maker's name begins after it.
static let catalystPrefix = "maccatalyst."
- /// Leading pairs of components that name no single developer, so for these the vendor takes three components:
- /// an account on a code host, a company under a country's registry (each in the Public Suffix List), or the app
- /// under what a tool writes when its maker sets none: `com.electron.<name>` from Electron's packagers, Qt's
- /// `com.yourcompany.<name>`, and ToDesktop's and install4j's own (install4j's names a project).
+ /// Leading pairs of components that name no single developer, so the vendor takes three: an account on a code
+ /// host, a company under a country's registry (Public Suffix List), or the app under a tool's default prefix.
private static let sharedDomains: Set<String> = [
"com.github", "io.github", "com.gitlab", "io.gitlab", "org.sourceforge", "net.sourceforge", "com.googlecode",
"uk.co", "uk.org", "uk.ac", "au.com", "au.net", "au.org", "jp.co", "jp.ne", "jp.or", "nz.co", "kr.co",
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swift
index 160d75f5..bd01fede 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swift
@@ -61,8 +61,7 @@ public struct SearchLocation: Sendable, Hashable {
self == .commandLineTools || self == .shellCompletions
}
- /// True for a folder inside a browser's own data, which goes with the browser, so the folders above it are
- /// not kept in place for it.
+ /// True for a folder in a browser's own data, which goes with the browser: no folder above it is kept for it.
var sitsInABrowsersOwnData: Bool {
self == .nativeMessagingHosts
}
diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/ShellReferences.swift b/Packages/PeelCore/Sources/PeelCore/Removal/ShellReferences.swift
index f458a101..8ce0e87b 100644
--- a/Packages/PeelCore/Sources/PeelCore/Removal/ShellReferences.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Removal/ShellReferences.swift
@@ -62,9 +62,8 @@ public enum ShellReferences {
/// A backslash or a dollar sign goes on with the name, as an escaped space or a variable does.
private static let endsAPath = Set(" \t\r\u{0B}\u{0C}/\"'`:;,|&()}]<>".utf8)
- /// The files zsh, bash and fish read when a shell starts: zsh's `.zshenv` where the session's ZDOTDIR or the
- /// home folder puts it, the other three in the folder zsh names once `.zshenv` has run, and the rest in the home
- /// folder.
+ /// The files zsh, bash and fish read when a shell starts: `.zshenv` where the session's ZDOTDIR or the home puts
+ /// it, zsh's other three in the folder zsh names once `.zshenv` has run, and the rest in the home folder.
static func startupFiles(home: URL) async -> [URL] {
var files: [URL] = []
let zdotdir = ShellSessions.sessionZDOTDIR
diff --git a/Packages/PeelCore/Sources/PeelCore/Terminal/PathBelowHome.swift b/Packages/PeelCore/Sources/PeelCore/Terminal/PathBelowHome.swift
index 20415ffd..82152bab 100644
--- a/Packages/PeelCore/Sources/PeelCore/Terminal/PathBelowHome.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Terminal/PathBelowHome.swift
@@ -29,9 +29,8 @@ extension String {
}
enum ShellCommand {
- /// The command that adds `lines` at the end of `file`, each on a line of its own, and makes the file when it is
- /// not there. An empty line goes first: a file whose last line has no newline after it would otherwise run into
- /// the first of `lines`, and the shell would read the two as one.
+ /// The command that adds each of `lines` on a line of its own at the end of `file`, making the file if needed. An
+ /// empty line goes first, so a last line with no newline after it never runs into the first of `lines`.
static func appending(_ lines: [String], to file: URL, home: URL) -> String {
let arguments = ([""] + lines).map(\.quotedForTheShell).joined(separator: " ")
return "printf '%s\\n' \(arguments) >> \(file.pathForTheShell(home: home))"
diff --git a/Packages/PeelCore/Sources/PeelCore/Terminal/ShellFile.swift b/Packages/PeelCore/Sources/PeelCore/Terminal/ShellFile.swift
index 53af2036..8c36f335 100644
--- a/Packages/PeelCore/Sources/PeelCore/Terminal/ShellFile.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Terminal/ShellFile.swift
@@ -80,11 +80,8 @@ public enum ShellFile {
return String(decoding: data, as: UTF8.self).split(separator: "\n").contains { reading.reads(String($0)) }
}
- /// Whether a line reads the file: `source` or `.` with the file's path as its argument, written from `$HOME`,
- /// `${HOME}` or `~`, or whole, in quotes or not, its spaces escaped or not, and not in a comment. Peel's own line
- /// tests the file first, `[[ -r … ]] && source …`, and counts only when that test starts a command: run into the
- /// line before it, as happened in a file whose last line had no newline, zsh fails on the line and never reaches
- /// the `source`. Made once for all the lines of a file, since making the patterns costs far more than a match.
+ /// Whether a line reads the file with `source` or `.`, outside a comment. Made once per file: patterns are costly.
+ /// Peel's `[[ -r … ]] && source …` counts only where its test starts a command, or zsh never reaches the `source`.
struct LineReading {
private let test: Regex<AnyRegexOutput>?
private let readsAfterTheTest: Regex<AnyRegexOutput>?
diff --git a/Packages/PeelCore/Sources/PeelCore/Terminal/ShellSessions.swift b/Packages/PeelCore/Sources/PeelCore/Terminal/ShellSessions.swift
index abc4bd89..4df16d50 100644
--- a/Packages/PeelCore/Sources/PeelCore/Terminal/ShellSessions.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Terminal/ShellSessions.swift
@@ -72,10 +72,8 @@ public enum ShellSessions: Sendable, Equatable {
await promptShown(home: home, zdotdir: Self.sessionZDOTDIR)
}
- /// Asks zsh for the prompt it shows: a login shell started as Terminal starts one, with the same environment,
- /// that reads every startup file, runs the `precmd` hooks as it would before its first prompt and prints
- /// `PROMPT` between marks, so what the startup files print before and `.zlogout` after is passed over. Nil when
- /// the shell is not zsh or zsh did not answer in time.
+ /// Asks the login shell, as Terminal starts it, for its prompt once every startup file and `precmd` hook has
+ /// run, read between marks so the files' output is skipped. Nil when it isn't zsh or doesn't answer in time.
func promptShown(home: URL, zdotdir: String?) async -> ShownPrompt? {
guard case .zsh = self else { return nil }
var environment = [
diff --git a/Packages/PeelCore/Sources/PeelCore/Tweaks/TweakStore.swift b/Packages/PeelCore/Sources/PeelCore/Tweaks/TweakStore.swift
index 42de26cb..a93c30e9 100644
--- a/Packages/PeelCore/Sources/PeelCore/Tweaks/TweakStore.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Tweaks/TweakStore.swift
@@ -62,10 +62,8 @@ public struct TweakStore: Sendable, TweakStoring {
return TweakState(isOn: isOn, isManaged: isManaged, text: text, heldElsewhere: elsewhere)
}
- /// What each layer macOS searches holds for a key. The layer Peel writes is the person's own for any host; a value
- /// set for this Mac alone comes before it, and after it, for a key of an app's domain, the person's global domain,
- /// then every account's layers of the app and of the global domain ("Preference Domains", Apple's Preferences
- /// Programming Topics for Core Foundation).
+ /// What each layer macOS searches holds for a key, in Apple's order ("Preference Domains"): this Mac alone, the
+ /// person's own (Peel's), the person's global domain, then every account's, for the app and for every app.
struct Layers {
var thisMac: CFPropertyList?
var own: CFPropertyList?
@@ -102,10 +100,8 @@ public struct TweakStore: Sendable, TweakStoring {
return layers
}
- /// Where the value in effect comes from when Peel can't change it from its own layer: a value set for this
- /// Mac alone wins over Peel's whatever it holds, and a switch read as on from a layer macOS falls back to,
- /// with nothing of Peel's over it, could not be turned off, since removing Peel's key would change nothing.
- /// A value Peel's own would win over, and a folder or a name, which Peel writes over it, are nobody else's.
+ /// Where a value Peel can't change from its own layer comes from: this Mac alone, which wins over Peel's, or, for a
+ /// switch on with nothing of Peel's, the layer macOS falls back to, since removing Peel's key would change nothing.
static func heldElsewhere(of kind: Tweak.Kind, isOn: Bool, in layers: Layers) -> TweakState.Elsewhere? {
if layers.thisMac != nil { return .thisMac }
guard layers.own == nil, case .aSwitch = kind, isOn else { return nil }
diff --git a/Packages/PeelCore/Sources/PeelCore/Updates/RequestWindow.swift b/Packages/PeelCore/Sources/PeelCore/Updates/RequestWindow.swift
index 3323759d..93ec3a09 100644
--- a/Packages/PeelCore/Sources/PeelCore/Updates/RequestWindow.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Updates/RequestWindow.swift
@@ -6,7 +6,6 @@ actor RequestWindow {
/// The App Store's, which every check in the process shares.
static let appStore = forTheAppStore()
- /// A window at the pace Apple gives for its lookup.
static func forTheAppStore() -> RequestWindow {
RequestWindow(limit: 20, window: .seconds(60))
}
diff --git a/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift b/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift
index 4b85764d..23c3869c 100644
--- a/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift
@@ -27,7 +27,6 @@ public struct UpdateChecker: Sendable {
}
private let session: URLSession
- /// The pace of requests to the App Store, which the process shares.
private let appStoreWindow: RequestWindow
private let country: String
private let systemVersion: String
@@ -96,10 +95,8 @@ public struct UpdateChecker: Sendable {
return own
}
- /// The status `answer(for:preference:casks:earlier:)` gives `app` without asking any server, from Homebrew's
- /// casks and the app's own files alone, or nil when the app's own feed or the App Store has to be asked.
- /// `known` is what that source answered last: where it had no answer, what Homebrew knows now answers in its
- /// place, as a check would, and once Homebrew knows nothing that counts, the source's own answer stands again.
+ /// The status `answer` gives `app` without asking a server, from Homebrew's casks and the app's own files, or nil
+ /// when its source must be asked. Where that source had no answer (`known`), Homebrew's counts, else `known`.
public func statusWithoutAsking(
for app: InstalledApp, preference: UpdateSource, casks: [HomebrewPackage], known: UpdateStatus? = nil
) -> UpdateStatus? {
@@ -145,9 +142,8 @@ public struct UpdateChecker: Sendable {
CaskEvidence.installedCask(for: app, in: casks).flatMap { Self.homebrewStatus(of: $0, at: clock()) }
}
- /// The status Homebrew reports at `now` for `cask`, which is already known to be the app's, or nil when it can't
- /// tell. A cask it doesn't mark outdated is up to date only while Homebrew's last check for new versions is less
- /// than `Homebrew.autoUpdateInterval` old, the longest Homebrew itself waits before it checks again.
+ /// The status Homebrew reports at `now` for `cask`, known to be the app's, or nil when it can't tell: a cask
+ /// not outdated is up to date only within `Homebrew.autoUpdateInterval` of Homebrew's last check for new versions.
static func homebrewStatus(of cask: HomebrewPackage, at now: Date) -> UpdateStatus? {
if cask.isOutdated, let latest = cask.latestVersion {
return .updateAvailable(version: latest, source: .homebrew, releaseNotes: cask.homepage)
@@ -396,9 +392,8 @@ public struct UpdateAnswer: Sendable, Hashable {
self.standsInFor = standsInFor
}
- /// The status to keep when this answer follows `previous`. A check whose own source failed keeps an update that
- /// source found earlier, even where Homebrew answered in its place, since failing to reach the server says
- /// nothing about that update. An update Homebrew reported is kept only while Homebrew gives it.
+ /// The status to keep after `previous`: a check whose own source failed keeps an update that source found earlier,
+ /// even where Homebrew answered in its place, and an update Homebrew reported is kept only while Homebrew gives it.
public func following(_ previous: UpdateStatus?) -> UpdateStatus {
if (standsInFor ?? status) == .failed, let previous, case .updateAvailable(_, let source, _) = previous,
source != .homebrew {
diff --git a/Packages/PeelCore/Sources/PeelCore/Updates/UpdateMemory.swift b/Packages/PeelCore/Sources/PeelCore/Updates/UpdateMemory.swift
index 484f5ea1..8a903fc2 100644
--- a/Packages/PeelCore/Sources/PeelCore/Updates/UpdateMemory.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Updates/UpdateMemory.swift
@@ -16,9 +16,7 @@ public struct UpdateMemory: Codable, Equatable, Sendable {
/// The developer's name from the App Store. It is saved because an App Store app's signature is Apple's and
/// does not name the developer, and the next check may be a week away.
public let developer: String?
- /// What the app's own feed or the App Store answered when `status` is Homebrew's answer in its place
- /// (`UpdateAnswer.standsInFor`). Homebrew's answer counts only while Homebrew gives it, and the app falls back to
- /// this once it doesn't.
+ /// What the app's own feed or the App Store answered, when `status` is Homebrew's answer in its place.
public let standsInFor: UpdateStatus?
/// The `UpdateChecker.revision` that gave the answer; nil for one saved before revisions were kept.
public let revision: Int?
diff --git a/Packages/PeelCore/Sources/PeelPrivileged/HelperLedger.swift b/Packages/PeelCore/Sources/PeelPrivileged/HelperLedger.swift
index 336666ca..a62daf65 100644
--- a/Packages/PeelCore/Sources/PeelPrivileged/HelperLedger.swift
+++ b/Packages/PeelCore/Sources/PeelPrivileged/HelperLedger.swift
@@ -104,10 +104,8 @@ public final class HelperLedger: Sendable {
guard let mode = item.mode, mode & S_IFMT == S_IFDIR, mode & 0o077 == 0, item.owner == geteuid() else {
return .failure(POSIXError(.EPERM))
}
- // Given to `user` so emptying the Trash asks for no password: the files while the folder is still
- // root's and closed to everyone else, since in the Trash they could no longer be listed without Full
- // Disk Access, and the folder itself only once it is there, through the descriptor held here, so the
- // ledger is never the user's where the helper reads it. A failed move takes the files back.
+ // Given to `user`, so emptying the Trash asks no password: the files here, while the folder is root's
+ // and closed, as the Trash can't be listed; the folder once there, not the user's where root reads it.
let inside = item.parent.child(item.name)
let entries = (try? FileManager.default.contentsOfDirectory(atPath: item.path)) ?? []
func giveEntries(to owner: uid_t) {
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/AttackRemovalGuardTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/AttackRemovalGuardTests.swift
index d105ab89..62143d04 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/AttackRemovalGuardTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/AttackRemovalGuardTests.swift
@@ -334,7 +334,6 @@ struct AttackRemovalGuardTests {
/// The hidden items tools share in the home folder, such as `.config` and `.zshrc`, are refused whatever an
/// app calls itself. Anything else inside a shared folder can still go.
- /// Peel looks inside these folders and never moves them whole, so neither may a folder on the way to one go.
@Test func theFolderAroundAPlacePeelLooksInside() throws {
let directory = try TemporaryDirectory()
let home = directory.url.appending(path: "home", directoryHint: .isDirectory)
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/DocumentationTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/DocumentationTests.swift
index 28c333f2..5eda80c4 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/DocumentationTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/DocumentationTests.swift
@@ -73,7 +73,6 @@ struct DocumentationTests {
#expect(wrong.isEmpty, "\(wrong)")
}
- /// PRIVACY.md promises that Settings > Privacy shows every address Peel or Homebrew may contact.
@Test func everyAddressPrivacyMDNamesIsInSettingsPrivacy() throws {
let privacy = try String(contentsOf: LineLengthTests.repository.appending(path: "PRIVACY.md"), encoding: .utf8)
let addresses = privacy.split(separator: "\n").compactMap { line in
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverMatcherTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverMatcherTests.swift
index 5b02434f..68c7d22e 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverMatcherTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverMatcherTests.swift
@@ -511,9 +511,6 @@ struct LeftoverMatcherTests {
#expect(Naming.withoutTrailingVersion("Numi") == nil)
}
- /// "Harbor Nightly" keeps its channel in the app's name but not in its folders, which the stable release uses
- /// too, so the folder is shown for review and never selected, and shared with the stable release while that one
- /// is installed.
@Test func showsForReviewAFolderNamedLikeTheAppWithoutItsChannelWord() throws {
let nightly = app("org.example.harbor-nightly", name: "Harbor Nightly")
let harbor = app("org.example.harbor", name: "Harbor")
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/PrivilegedPathPolicyTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/PrivilegedPathPolicyTests.swift
index 3384cdff..e408aa74 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/PrivilegedPathPolicyTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/PrivilegedPathPolicyTests.swift
@@ -285,8 +285,6 @@ struct PrivilegedPathPolicyTests {
#expect(PrivilegedPathPolicy.isValidLabel(label) == isValid)
}
- /// A folder on the way to a place Peel searches stays where a move is asked, but one a helper moved whole before
- /// that rule held may come back from the Trash, as a folder only, so History stays the way back.
@Test func putsBackAFolderOnTheWayToAPlacePeelSearchesAsAFolderOnly() throws {
let directory = try TemporaryDirectory()
let policy = try policy(in: directory)
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/ScreenshotFolderTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/ScreenshotFolderTests.swift
index c646fc0c..4322e1cc 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/ScreenshotFolderTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/ScreenshotFolderTests.swift
@@ -27,7 +27,6 @@ struct ScreenshotFolderTests {
#expect(ScreenshotFolder.problem(with: shots, home: directory.url) == .notWritable)
}
- /// The setting is the folder's path as the person would write it, with no slash at the end.
@Test func aFolderFromBeforeOnADiskThatIsNotConnectedMayStillTakeScreenshots() throws {
let directory = try TemporaryDirectory()
let away = "/Volumes/PeelTests-\(UUID().uuidString)/Screenshots"
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/TrashServiceTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/TrashServiceTests.swift
index b063a34b..31febce6 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/TrashServiceTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/TrashServiceTests.swift
@@ -1319,8 +1319,6 @@ struct TrashServiceTests {
#expect(result.failures.map(\.url) == [stayed])
}
- /// Without Full Disk Access macOS lets Peel search the Trash but not list it, so what the helper moved is
- /// looked for under the names the helper gives.
@Test(.permissionsHold) func whatTheHelperMovedIsFoundAgainInATrashPeelMayNotRead() throws {
let directory = try TemporaryDirectory()
let trash = try directory.directory("home/.Trash")
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/TweakLedgerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/TweakLedgerTests.swift
index a19e14eb..26fe23c8 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/TweakLedgerTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/TweakLedgerTests.swift
@@ -160,8 +160,6 @@ struct TweakLedgerTests {
#expect(store.values[name.id] as? String == "ss")
}
- /// Once what the key held before is forgotten, turning the tweak off hands the setting to macOS, as for a
- /// setting made outside Peel: for a folder that can no longer take screenshots.
@Test func aForgottenPreviousValueHandsTheSettingToMacOS() throws {
let folder = try #require(TweakCatalog.all.first { $0.kind == .folder })
let store = FakeStore()
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/TweakTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/TweakTests.swift
index bcdb0035..87c023cb 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/TweakTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/TweakTests.swift
@@ -123,9 +123,6 @@ struct TweakTests {
#expect(!TweakStore.matches("zero" as CFString, .number(0)))
}
- /// A value Peel can't change from the layer it writes is named by where it comes from: a value set for this
- /// Mac alone wins over Peel's, and a switch on from an administrator's file or from the global domain, with
- /// nothing of Peel's over it, could not be turned off. A value Peel's own would win over is nobody else's.
@Test func tellsWhereAValueComesFromThatPeelCannotChange() {
let aSwitch = Tweak.Kind.aSwitch(.boolean(true))
let forThisApp = Tweak.Kind.aSwitchForThisAppAlone(.boolean(true))
diff --git a/Peel/Model/AppLibrary.swift b/Peel/Model/AppLibrary.swift
index 65537655..3fc85ee0 100644
--- a/Peel/Model/AppLibrary.swift
+++ b/Peel/Model/AppLibrary.swift
@@ -148,7 +148,6 @@ final class AppLibrary {
/// What is new in each waiting update, read at launch, so a page shows it with no connection too.
private(set) var releaseNotes = ReleaseNotesMemory()
private let releaseNotesStore: ReleaseNotesStore
- /// Where the update round's memory and the person's update preferences are kept.
private let defaults: UserDefaults
/// Apps shown from outside the scanned folders, such as one in Downloads or in the Trash. Kept apart,
/// because the next reading of the folders doesn't find them and would drop their row and their page.
@@ -163,8 +162,6 @@ final class AppLibrary {
private let updateChecker: UpdateChecker
private let teamRegistry = TeamRegistry()
- /// The stores are Peel's own unless a test passes its own, so a test of the update round writes nothing of the
- /// person's.
init(
defaults: UserDefaults = .standard,
updateChecker: UpdateChecker = UpdateChecker(),
@@ -296,7 +293,6 @@ final class AppLibrary {
/// The round of checks Rescan started, which the next Rescan stops before it starts its own.
@ObservationIgnored private(set) var recheck: Task<Void, Never>?
- /// Asks about every app's updates now, whatever each one's schedule says.
func checkEveryAppAgain() {
recheck?.cancel()
recheck = Task { await checkForUpdates(apps, force: true) }
@@ -810,11 +806,9 @@ final class AppLibrary {
UpdateMemoryStore.save(memory, to: defaults)
}
- /// Shows what a check would answer now without asking any server, for each app Homebrew installed and each app
- /// whose last answer is Homebrew's in place of its own source: what Homebrew's casks and the app's own files
- /// decide, and what Homebrew knows where that source had no answer, for as long as it counts. Reading Homebrew
- /// costs no network request, so this doesn't wait for the update schedule, and Applications agrees with the
- /// Homebrew page.
+ /// Shows what a check would answer without asking a server, for each app Homebrew installed or answers for in place
+ /// of its own source. Reading Homebrew costs no network request, so this doesn't wait for the update schedule, and
+ /// Applications agrees with the Homebrew page.
private func applyHomebrewStatuses() {
let preference = updateSource
for app in apps where isAskedAboutUpdates(app) {
diff --git a/Peel/Model/GitLibrary.swift b/Peel/Model/GitLibrary.swift
index 7376bd06..8794a1df 100644
--- a/Peel/Model/GitLibrary.swift
+++ b/Peel/Model/GitLibrary.swift
@@ -24,8 +24,6 @@ final class GitLibrary {
private var waiting: [GitSetting: Int] = [:]
private var changes: Task<Void, Never>?
- /// The home whose Git settings are read and changed, and the store the ledger is kept in; the person's own
- /// unless a test gives its own.
init(home: URL = .homeDirectory, defaults: UserDefaults = .standard) {
self.home = home
self.defaults = defaults
diff --git a/Peel/Model/SSHLibrary.swift b/Peel/Model/SSHLibrary.swift
index 31e7b866..d297aaee 100644
--- a/Peel/Model/SSHLibrary.swift
+++ b/Peel/Model/SSHLibrary.swift
@@ -17,8 +17,6 @@ final class SSHLibrary {
private(set) var state: State?
private(set) var wasRefused = false
- /// Peel's own file in `folder`, and the home whose `.ssh/config` is read: the person's own unless a test gives
- /// its own.
init(folder: URL = PeelFolder.url, home: URL = .homeDirectory) {
file = SSHFile.url(in: folder)
config = home.appending(path: ".ssh/config", directoryHint: .notDirectory)
diff --git a/Peel/Model/ShellLibrary.swift b/Peel/Model/ShellLibrary.swift
index 2b0882f3..631aa479 100644
--- a/Peel/Model/ShellLibrary.swift
+++ b/Peel/Model/ShellLibrary.swift
@@ -21,8 +21,6 @@ final class ShellLibrary {
private(set) var wasRefused = false
private(set) var draft = Prompt()
- /// Peel's own file in `folder`, and the home whose startup files are read: the person's own unless a test gives
- /// its own.
init(folder: URL = PeelFolder.url, home: URL = .homeDirectory) {
file = ShellFile.url(in: folder)
self.home = home
diff --git a/Peel/Model/TerminalLibrary.swift b/Peel/Model/TerminalLibrary.swift
index 810d6b1f..2427f64c 100644
--- a/Peel/Model/TerminalLibrary.swift
+++ b/Peel/Model/TerminalLibrary.swift
@@ -34,8 +34,6 @@ final class TerminalLibrary {
var waitingForTerminal: Action?
var terminalDidNotQuit = false
- /// Terminal's settings, the store the ledger is kept in, and the home whose `.hushlogin` is read: the person's
- /// own unless a test gives its own.
init(
settings: any TerminalSettingsStoring = TerminalSettings(),
defaults: UserDefaults = .standard,
@@ -61,7 +59,6 @@ final class TerminalLibrary {
showsWindowSwitch = TerminalWindows.switchMatters()
}
- /// Lets go of the last refusal, as the page goes: its reason was shown where the switch went back.
func forgetRefusal() {
wasRefused = false
}
diff --git a/Peel/Model/TweakLibrary.swift b/Peel/Model/TweakLibrary.swift
index 610d6c43..c4f43503 100644
--- a/Peel/Model/TweakLibrary.swift
+++ b/Peel/Model/TweakLibrary.swift
@@ -21,7 +21,6 @@ final class TweakLibrary {
private let store: any TweakStoring
private let defaults: UserDefaults
private let home: URL
- /// Restarts the process that owns a setting; `TweakRestart.run` unless a test gives its own.
private let restart: @Sendable (Tweak.Restart) async -> Void
/// What Peel changed, and the values from before. `TweakLedger` decides what turning a switch on or off
/// does, and is tested there.
@@ -32,9 +31,6 @@ final class TweakLibrary {
/// saved with the session ID, so they survive quitting Peel and are dropped after the next login.
private(set) var waitingForLogOut: Set<Tweak.ID>
- /// The preferences the tweaks are read from and written to, the store the ledger is kept in, the home whose
- /// Trash a screenshot folder is checked against, and what restarts a process: the person's own unless a test
- /// gives its own.
init(
store: any TweakStoring = TweakStore(),
defaults: UserDefaults = .standard,
@@ -170,7 +166,6 @@ final class TweakLibrary {
/// with no reason. A tweak leaves the set with its next write that lands, and all of them when the page goes.
private(set) var refused: Set<Tweak.ID> = []
- /// Forgets what the rows say about the last changes, when the page goes.
func forgetNotices() {
refused = []
foldersLeftToMacOS = []
diff --git a/Peel/Views/Terminal/ShellTab.swift b/Peel/Views/Terminal/ShellTab.swift
index 005207b2..4c8f8ce6 100644
--- a/Peel/Views/Terminal/ShellTab.swift
+++ b/Peel/Views/Terminal/ShellTab.swift
@@ -195,9 +195,8 @@ private struct PromptSection: View {
}
}
- /// Why zsh shows another prompt than Peel's, as zsh itself answered: Peel's line not read yet, a function that
- /// sets the prompt before each command, or a line after Peel's. When zsh did not answer, what the startup file
- /// says.
+ /// Why zsh shows another prompt than Peel's, as zsh answered: Peel's line not read yet, a function that sets it
+ /// before each command, or a line after Peel's; when zsh didn't answer, what the startup file says.
private static func notice(for prompt: Prompt, in state: ShellLibrary.State) -> Text? {
guard let startupFile = state.startupFile else { return nil }
guard state.isSourced else {
diff --git a/Peel/Views/UpdateStatusBadge.swift b/Peel/Views/UpdateStatusBadge.swift
index 59a7cce2..bb056e2f 100644
--- a/Peel/Views/UpdateStatusBadge.swift
+++ b/Peel/Views/UpdateStatusBadge.swift
@@ -7,7 +7,6 @@ struct UpdateStatusBadge: View {
let isChecking: Bool
/// When a check last got an answer, which is what the note for a failed check tells the user.
var lastCheck: Date?
- /// The cask the app came from, when only Homebrew could answer for it and Homebrew's last check is too old to tell.
var caskNotCheckedRecently: HomebrewPackage?
var body: some View {
diff --git a/PeelTests/AppLibraryTests.swift b/PeelTests/AppLibraryTests.swift
index 45ff16cd..f9dbd4ef 100644
--- a/PeelTests/AppLibraryTests.swift
+++ b/PeelTests/AppLibraryTests.swift
@@ -4,7 +4,6 @@ import PeelCore
import Synchronization
import Testing
-/// Answers every request with one appcast, and sends nothing anywhere.
private nonisolated final class AppcastProtocol: URLProtocol, @unchecked Sendable {
static let body = Mutex(Data())
@@ -22,7 +21,6 @@ private nonisolated final class AppcastProtocol: URLProtocol, @unchecked Sendabl
}
}
-/// Holds every request until the test lets it through, so a round of checks can be caught while it waits.
private nonisolated final class HeldProtocol: URLProtocol, @unchecked Sendable {
static let body = Mutex(Data())
static let arrived = Mutex<AsyncStream<Void>.Continuation?>(nil)
diff --git a/PeelTests/MadeUpDefaults.swift b/PeelTests/MadeUpDefaults.swift
index 745fab99..e52d96bf 100644
--- a/PeelTests/MadeUpDefaults.swift
+++ b/PeelTests/MadeUpDefaults.swift
@@ -1,10 +1,8 @@
import Foundation
import Testing
-/// A preference domain of a test's own, kept in a folder of its own: a suite named by a path lives at that path,
-/// so cfprefsd writes nothing for it in the real Preferences folder, and forgetting it removes the folder. A domain
-/// named like an app's would get a file there, which cfprefsd writes again on its own time once the test has let
-/// the domain go.
+/// A preference domain kept at a path of the test's own, so cfprefsd writes nothing in the real Preferences folder,
+/// where a domain named like an app's would get a file that cfprefsd writes again after the test has let it go.
struct MadeUpDefaults {
private let folder: URL
let defaults: UserDefaults
diff --git a/PeelTests/TerminalLibrariesTests.swift b/PeelTests/TerminalLibrariesTests.swift
index a9e41fcb..9742f723 100644
--- a/PeelTests/TerminalLibrariesTests.swift
+++ b/PeelTests/TerminalLibrariesTests.swift
@@ -3,7 +3,6 @@ import Foundation
import PeelCore
import Testing
-/// Terminal's settings as a test keeps them in memory, never Terminal's own.
private final class FakeTerminalSettings: TerminalSettingsStoring {
var isTerminalOpen = false
var isManaged = false
@@ -37,7 +36,6 @@ struct TerminalLibrariesTests {
return home
}
- /// A file Peel refuses to read, larger than it ever writes.
private func unreadableFile(at url: URL) throws -> Int {
try FileManager.default.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true)
let bytes = Data(repeating: UInt8(ascii: "#"), count: 65 * 1_024)
diff --git a/PeelTests/TweakLibraryTests.swift b/PeelTests/TweakLibraryTests.swift
index 9bb72b2f..64c3aa54 100644
--- a/PeelTests/TweakLibraryTests.swift
+++ b/PeelTests/TweakLibraryTests.swift
@@ -3,7 +3,6 @@ import Foundation
import PeelCore
import Testing
-/// Tweak settings as a test keeps them in memory, never the Mac's own.
private final class FakeTweakStore: TweakStoring {
var values: [String: Any] = [:]
var refuses: Set<Tweak.ID> = []