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.

Wrap the app's long lines at 120 columns

Țugui Dragoș9522e000612c
diff --git a/Peel/FrameWatch.swift b/Peel/FrameWatch.swift
index 8002c164..1eca4980 100644
--- a/Peel/FrameWatch.swift
+++ b/Peel/FrameWatch.swift
@@ -10,7 +10,9 @@ import SwiftUI
/// It is in every build, not only Debug, because Release timings are the ones that count. Its display link wakes
/// Peel every frame, so leave it off when measuring idle CPU.
final class FrameWatch: NSObject {
- static let shared = ProcessInfo.processInfo.environment["PEEL_MEASURE"].flatMap { MeasureFile(named: $0) }.map { FrameWatch(file: $0) }
+ static let shared = ProcessInfo.processInfo.environment["PEEL_MEASURE"]
+ .flatMap { MeasureFile(named: $0) }
+ .map { FrameWatch(file: $0) }
private let file: MeasureFile
private var hitches = Hitches()
@@ -97,7 +99,11 @@ final class FrameWatch: NSObject {
}
request.resume()
self.request = request
- NotificationCenter.default.addObserver(forName: NSApplication.willTerminateNotification, object: nil, queue: nil) { [weak self] _ in
+ NotificationCenter.default.addObserver(
+ forName: NSApplication.willTerminateNotification,
+ object: nil,
+ queue: nil
+ ) { [weak self] _ in
MainActor.assumeIsolated { self?.report() }
}
}
diff --git a/Peel/HomeSnapshot.swift b/Peel/HomeSnapshot.swift
index 401c8856..b9a19d83 100644
--- a/Peel/HomeSnapshot.swift
+++ b/Peel/HomeSnapshot.swift
@@ -20,16 +20,61 @@ enum HomeSnapshot {
for scheme in [ColorScheme.light, .dark] {
for contrast in [ColorSchemeContrast.standard, .increased] {
let name = (scheme == .light ? "light" : "dark") + (contrast == .increased ? "-contrast" : "")
- render(HomeContent().environment(home).environment(helper).environment(stats), width: 360, height: 760, on: window, scheme: scheme, contrast: contrast, to: "\(directory)/home-content-\(name).png")
+ render(
+ HomeContent().environment(home).environment(helper).environment(stats),
+ width: 360,
+ height: 760,
+ on: window,
+ scheme: scheme,
+ contrast: contrast,
+ to: "\(directory)/home-content-\(name).png"
+ )
// Home again with Show Borders on, for this image only. The stickers then outline their edges.
if contrast == .standard {
- render(HomeContent().environment(home).environment(helper).environment(stats).environment(\._accessibilityShowButtonShapes, true), width: 360, height: 760, on: window, scheme: scheme, to: "\(directory)/home-content-borders-\(name).png")
+ render(
+ HomeContent().environment(home).environment(helper).environment(stats)
+ .environment(\._accessibilityShowButtonShapes, true),
+ width: 360,
+ height: 760,
+ on: window,
+ scheme: scheme,
+ to: "\(directory)/home-content-borders-\(name).png"
+ )
}
// The permissions at their widest, and at their narrowest, where Home puts its two halves side by side.
- render(HomePermissionsContent().environment(home).environment(helper).environment(ExclusionsStore.shared), width: 720, on: window, scheme: scheme, contrast: contrast, to: "\(directory)/home-detail-\(name).png")
- render(HomePermissionsContent().environment(home).environment(helper).environment(ExclusionsStore.shared), width: 480, on: window, scheme: scheme, contrast: contrast, to: "\(directory)/detail-narrow-\(name).png")
- render(AboutContent().environment(AppLibrary()).fixedSize(horizontal: false, vertical: true), width: AboutContent.width, on: Album.sheet, scheme: scheme, contrast: contrast, to: "\(directory)/about-\(name).png")
- render(MenuBarPanel().environment(AppLibrary()).environment(stats).environment(found), width: 320, scheme: scheme, contrast: contrast, to: "\(directory)/menu-bar-\(name).png")
+ render(
+ HomePermissionsContent().environment(home).environment(helper)
+ .environment(ExclusionsStore.shared),
+ width: 720,
+ on: window,
+ scheme: scheme,
+ contrast: contrast,
+ to: "\(directory)/home-detail-\(name).png"
+ )
+ render(
+ HomePermissionsContent().environment(home).environment(helper)
+ .environment(ExclusionsStore.shared),
+ width: 480,
+ on: window,
+ scheme: scheme,
+ contrast: contrast,
+ to: "\(directory)/detail-narrow-\(name).png"
+ )
+ render(
+ AboutContent().environment(AppLibrary()).fixedSize(horizontal: false, vertical: true),
+ width: AboutContent.width,
+ on: Album.sheet,
+ scheme: scheme,
+ contrast: contrast,
+ to: "\(directory)/about-\(name).png"
+ )
+ render(
+ MenuBarPanel().environment(AppLibrary()).environment(stats).environment(found),
+ width: 320,
+ scheme: scheme,
+ contrast: contrast,
+ to: "\(directory)/menu-bar-\(name).png"
+ )
}
}
NSApp.terminate(nil)
@@ -37,13 +82,23 @@ enum HomeSnapshot {
/// Saves `view` as a PNG at `path`, `width` wide and `height` tall, or as tall as it needs when `height` is nil.
/// Increase Contrast is set through `_colorSchemeContrast`, the setter SwiftUI keeps for previews.
- private static func render(_ view: some View, width: CGFloat, height: CGFloat? = nil, on backdrop: Color = .clear, scheme: ColorScheme, contrast: ColorSchemeContrast = .standard, to path: String) {
+ private static func render(
+ _ view: some View,
+ width: CGFloat,
+ height: CGFloat? = nil,
+ on backdrop: Color = .clear,
+ scheme: ColorScheme,
+ contrast: ColorSchemeContrast = .standard,
+ to path: String
+ ) {
let content = view.frame(width: width, height: height).background(backdrop)
.environment(\.colorScheme, scheme)
.environment(\._colorSchemeContrast, contrast)
let renderer = ImageRenderer(content: content)
renderer.scale = 2
- guard let image = renderer.nsImage, let data = image.tiffRepresentation, let bitmap = NSBitmapImageRep(data: data) else { return }
+ guard let image = renderer.nsImage, let data = image.tiffRepresentation,
+ let bitmap = NSBitmapImageRep(data: data)
+ else { return }
try? bitmap.representation(using: .png, properties: [:])?.write(to: URL(filePath: path))
}
}
diff --git a/Peel/Model/AppLibrary.swift b/Peel/Model/AppLibrary.swift
index dfc831d5..0a23a013 100644
--- a/Peel/Model/AppLibrary.swift
+++ b/Peel/Model/AppLibrary.swift
@@ -127,11 +127,14 @@ final class AppLibrary {
/// The apps selected with their checkboxes, to be removed together. Kept apart from `selection`, so
/// choosing a row to look at never clears the batch.
var picked: Set<InstalledApp.ID> = []
- private(set) var ignoredIdentifiers = Set(UserDefaults.standard.stringArray(forKey: SettingsKey.ignoredUpdateApps) ?? []) {
+ private(set) var ignoredIdentifiers = Set(
+ UserDefaults.standard.stringArray(forKey: SettingsKey.ignoredUpdateApps) ?? []
+ ) {
didSet { updatesRevision += 1 }
}
- private(set) var skippedVersions = UserDefaults.standard.dictionary(forKey: SettingsKey.skippedUpdateVersions) as? [String: String] ?? [:] {
+ private(set) var skippedVersions = UserDefaults.standard.dictionary(forKey: SettingsKey.skippedUpdateVersions)
+ as? [String: String] ?? [:] {
didSet { updatesRevision += 1 }
}
var sort = AppSort.name
@@ -281,7 +284,9 @@ final class AppLibrary {
/// The revealed apps that are still on disk and that the new reading of the folders did not find.
private func stillThere(_ revealed: [InstalledApp], beside found: [InstalledApp]) -> [InstalledApp] {
let listed = Set(found.map(\.id))
- return revealed.filter { !listed.contains($0.id) && FileManager.default.fileExists(atPath: $0.url.path(percentEncoded: false)) }
+ return revealed.filter {
+ !listed.contains($0.id) && FileManager.default.fileExists(atPath: $0.url.path(percentEncoded: false))
+ }
}
/// Restores the update answers saved by earlier runs, for apps still at the build they describe.
@@ -327,7 +332,8 @@ final class AppLibrary {
while let (id, size) = await group.next() {
// A walk given up because the list changed says nothing about the bundle, and a bundle replaced
// while it was walked is another build, so neither answer is kept.
- if !Task.isCancelled, let app = measured[id], apps.contains(where: { $0.id == id && Self.isTheSameBuild($0, app) }) {
+ if !Task.isCancelled, let app = measured[id],
+ apps.contains(where: { $0.id == id && Self.isTheSameBuild($0, app) }) {
if let size {
sizes[id] = size
unmeasured.remove(id)
@@ -393,7 +399,9 @@ final class AppLibrary {
/// The apps the user excluded. Worked out again only when the apps or the exclusions change, since each
/// check resolves the app's path on disk.
func excludedIDs(by exclusions: Exclusions) -> Set<InstalledApp.ID> {
- if let lastExcluded, lastExcluded.revision == revision, lastExcluded.exclusions == exclusions { return lastExcluded.ids }
+ if let lastExcluded, lastExcluded.revision == revision, lastExcluded.exclusions == exclusions {
+ return lastExcluded.ids
+ }
let ids = Set(apps.filter(exclusions.excludes).map(\.id))
lastExcluded = (revision, exclusions, ids)
return ids
@@ -508,7 +516,9 @@ final class AppLibrary {
var pending = wanted.makeIterator()
for _ in 0..<Self.concurrentUpdateChecks {
guard let app = pending.next() else { break }
- _ = group.addTaskUnlessCancelled { (app.id, await checker.answer(for: app, preference: preference, casks: casks)) }
+ _ = group.addTaskUnlessCancelled {
+ (app.id, await checker.answer(for: app, preference: preference, casks: casks))
+ }
}
while case let (id, answer)? = await group.next() {
let status = answer.status
@@ -521,7 +531,9 @@ final class AppLibrary {
// what was known and put off the next check for hours.
guard !Task.isCancelled else { continue }
// The answer describes the build that was asked about, which may have been replaced since.
- guard let app = asked[id], apps.contains(where: { $0.id == id && Self.isTheSameBuild($0, app) }) else { continue }
+ guard let app = asked[id], apps.contains(where: { $0.id == id && Self.isTheSameBuild($0, app) }) else {
+ continue
+ }
let kept = status.following(updateStatuses[id])
updateStatuses[id] = kept
if status != .failed {
@@ -536,7 +548,9 @@ final class AppLibrary {
developer: answer.developer ?? memory[identifier]?.developer
)
if let app = pending.next() {
- _ = group.addTaskUnlessCancelled { (app.id, await checker.answer(for: app, preference: preference, casks: casks)) }
+ _ = group.addTaskUnlessCancelled {
+ (app.id, await checker.answer(for: app, preference: preference, casks: casks))
+ }
}
}
}
@@ -547,7 +561,11 @@ final class AppLibrary {
/// The user's update settings as one value. The command line reads the same settings from the same keys,
/// so the app and `peel` can't disagree about what is waiting.
var updatePreferences: UpdatePreferences {
- UpdatePreferences(source: updateSource, ignoredIdentifiers: ignoredIdentifiers, skippedVersions: skippedVersions)
+ UpdatePreferences(
+ source: updateSource,
+ ignoredIdentifiers: ignoredIdentifiers,
+ skippedVersions: skippedVersions
+ )
}
/// Whether an update is waiting for `app`. An ignored app has none, and neither has one whose waiting
@@ -709,7 +727,10 @@ final class AppLibrary {
/// change again on every launch until the user acknowledges it.
func checkSigningTeams() async {
let outcome = await teamRegistry.check(apps)
- teamChanges = Dictionary(outcome.changes.map { ($0.bundleIdentifier, $0) }, uniquingKeysWith: { first, _ in first })
+ teamChanges = Dictionary(
+ outcome.changes.map { ($0.bundleIdentifier, $0) },
+ uniquingKeysWith: { first, _ in first }
+ )
teamRecordProblem = outcome.problem
}
@@ -771,10 +792,15 @@ final class AppLibrary {
/// elsewhere, such as a helper or a Nightly build on another disk. The identifier itself when macOS knows none.
func name(forBundleIdentifier bundleIdentifier: String) -> String {
if lastNames?.revision != revision {
- lastNames = (revision, Dictionary(apps.map { ($0.bundleIdentifier, $0.name) }, uniquingKeysWith: { first, _ in first }))
+ lastNames = (
+ revision,
+ Dictionary(apps.map { ($0.bundleIdentifier, $0.name) }, uniquingKeysWith: { first, _ in first })
+ )
}
if let name = lastNames?.names[bundleIdentifier] { return name }
- let name = AppInspector.applicationURL(forBundleIdentifier: bundleIdentifier).map(AppInspector.displayName(of:)) ?? bundleIdentifier
+ let name =
+ AppInspector.applicationURL(forBundleIdentifier: bundleIdentifier).map(AppInspector.displayName(of:))
+ ?? bundleIdentifier
lastNames?.names[bundleIdentifier] = name
return name
}
diff --git a/Peel/Model/BackgroundItemLibrary.swift b/Peel/Model/BackgroundItemLibrary.swift
index a5655739..f5ecad22 100644
--- a/Peel/Model/BackgroundItemLibrary.swift
+++ b/Peel/Model/BackgroundItemLibrary.swift
@@ -25,7 +25,11 @@ final class BackgroundItemLibrary {
func refresh(installedApps: [InstalledApp]) async {
self.installedApps = installedApps
- guard let result = await scanRun.run({ await BackgroundItems.scan(installedApps: installedApps, exclusions: ExclusionsStore.shared.exclusions) }) else { return }
+ guard
+ let result = await scanRun.run({
+ await BackgroundItems.scan(installedApps: installedApps, exclusions: ExclusionsStore.shared.exclusions)
+ })
+ else { return }
items = result
if let selection, items?.contains(where: { $0.id == selection }) != true {
self.selection = nil
diff --git a/Peel/Model/BulkRemovalPlan.swift b/Peel/Model/BulkRemovalPlan.swift
index eef706f8..b6286e25 100644
--- a/Peel/Model/BulkRemovalPlan.swift
+++ b/Peel/Model/BulkRemovalPlan.swift
@@ -69,7 +69,12 @@ final class BulkRemovalPlan {
/// The revision of the exclusions the last scan read, nil before the first.
private(set) var exclusionsRevision: Int?
- func refresh(installedApps: [InstalledApp], canUseHelper: Bool, casks: [HomebrewPackage] = [], receipts: Set<String> = []) async {
+ func refresh(
+ installedApps: [InstalledApp],
+ canUseHelper: Bool,
+ casks: [HomebrewPackage] = [],
+ receipts: Set<String> = []
+ ) async {
self.canUseHelper = canUseHelper
let apps = apps
guard let (result, revision) = await scanRun.run({
diff --git a/Peel/Model/CloudLibrary.swift b/Peel/Model/CloudLibrary.swift
index f328fc7a..62d77f26 100644
--- a/Peel/Model/CloudLibrary.swift
+++ b/Peel/Model/CloudLibrary.swift
@@ -50,7 +50,11 @@ final class CloudLibrary {
/// Scans again. What the last Free Up Space refused is cleared, since it described the old list.
func refresh() async {
refusals = []
- guard let scan = await scanRun.run({ await CloudStorage.downloaded(exclusions: ExclusionsStore.shared.exclusions) }) else { return }
+ guard
+ let scan = await scanRun.run({
+ await CloudStorage.downloaded(exclusions: ExclusionsStore.shared.exclusions)
+ })
+ else { return }
files = scan.files
wasCutShort = scan.wasCutShort
couldNotRead = scan.couldNotRead
diff --git a/Peel/Model/DeveloperLibrary.swift b/Peel/Model/DeveloperLibrary.swift
index 95a550e7..d2df3b6e 100644
--- a/Peel/Model/DeveloperLibrary.swift
+++ b/Peel/Model/DeveloperLibrary.swift
@@ -18,7 +18,11 @@ final class DeveloperLibrary {
}
func refresh() async {
- guard let result = await scanRun.run({ await DeveloperCaches.scan(exclusions: ExclusionsStore.shared.exclusions) }) else { return }
+ guard
+ let result = await scanRun.run({
+ await DeveloperCaches.scan(exclusions: ExclusionsStore.shared.exclusions)
+ })
+ else { return }
environments = result
let locations = result.flatMap(\.locations)
selectedURLs = choices.update(
diff --git a/Peel/Model/DuplicateLibrary.swift b/Peel/Model/DuplicateLibrary.swift
index b6ee88a8..4f559e88 100644
--- a/Peel/Model/DuplicateLibrary.swift
+++ b/Peel/Model/DuplicateLibrary.swift
@@ -79,9 +79,14 @@ final class DuplicateLibrary {
groupCount = 0
return
}
- reclaimable = Dictionary(scan.groups.flatMap(\.files).map { ($0.url, $0.reclaimableSize) }) { first, _ in first }
- reclaimableFolders = Dictionary(scan.folderGroups.flatMap(\.folders).map { ($0.url, $0.reclaimableSize) }) { first, _ in first }
- copyCount = scan.groups.reduce(0) { $0 + $1.files.count } + scan.folderGroups.reduce(0) { $0 + $1.folders.count }
+ reclaimable = Dictionary(
+ scan.groups.flatMap(\.files).map { ($0.url, $0.reclaimableSize) }
+ ) { first, _ in first }
+ reclaimableFolders = Dictionary(
+ scan.folderGroups.flatMap(\.folders).map { ($0.url, $0.reclaimableSize) }
+ ) { first, _ in first }
+ copyCount =
+ scan.groups.reduce(0) { $0 + $1.files.count } + scan.folderGroups.reduce(0) { $0 + $1.folders.count }
groupCount = scan.groups.count + scan.folderGroups.count
}
@@ -148,7 +153,10 @@ final class DuplicateLibrary {
options.minimumSize = minimumSize
let exclusions = ExclusionsStore.shared.exclusions
- let (updates, continuation) = AsyncStream.makeStream(of: DuplicateScanProgress.self, bufferingPolicy: .bufferingNewest(1))
+ let (updates, continuation) = AsyncStream.makeStream(
+ of: DuplicateScanProgress.self,
+ bufferingPolicy: .bufferingNewest(1)
+ )
let progressUpdates = Task {
for await update in updates {
// A scan stopped or replaced reports on until it notices, over the newer scan's progress otherwise.
diff --git a/Peel/Model/ExtensionLibrary.swift b/Peel/Model/ExtensionLibrary.swift
index 175aa9f7..051963fc 100644
--- a/Peel/Model/ExtensionLibrary.swift
+++ b/Peel/Model/ExtensionLibrary.swift
@@ -17,7 +17,8 @@ final class ExtensionLibrary {
}
func refresh() async {
- guard let scan = await scanRun.run({ await AppExtensions.scan(exclusions: ExclusionsStore.shared.exclusions) }) else { return }
+ guard let scan = await scanRun.run({ await AppExtensions.scan(exclusions: ExclusionsStore.shared.exclusions) })
+ else { return }
let result = scan.extensions
extensions = result
unanswered = scan.unanswered
diff --git a/Peel/Model/FileSearchLibrary.swift b/Peel/Model/FileSearchLibrary.swift
index 03341e4a..cd97545c 100644
--- a/Peel/Model/FileSearchLibrary.swift
+++ b/Peel/Model/FileSearchLibrary.swift
@@ -51,7 +51,9 @@ final class FileSearchLibrary {
}
results = found
filteredBy = exclusions
- selectableURLs = Set(found.files.filter { !$0.requiresPrivileges && !$0.belongsToAnApp && !$0.isInTheCloud }.map(\.url))
+ selectableURLs = Set(
+ found.files.filter { !$0.requiresPrivileges && !$0.belongsToAnApp && !$0.isInTheCloud }.map(\.url)
+ )
sizes = Dictionary(found.files.map { ($0.url, $0.size) }, uniquingKeysWith: { first, _ in first })
selectedURLs.formIntersection(found.files.filter { !$0.requiresPrivileges }.map(\.url))
// The search ran under the exclusions as they were when it started, so leave out anything excluded since.
diff --git a/Peel/Model/FoundLastTimeStore.swift b/Peel/Model/FoundLastTimeStore.swift
index a339bb1a..5c46fe7f 100644
--- a/Peel/Model/FoundLastTimeStore.swift
+++ b/Peel/Model/FoundLastTimeStore.swift
@@ -89,7 +89,10 @@ extension DuplicateLibrary {
var looked: Looked? {
scan.map { scan in
let reclaimable = (scan.groups.map(\.reclaimableSize) + scan.folderGroups.map(\.reclaimableSize)).cappedSum
- return Looked(count: scan.groups.count + scan.folderGroups.count, size: SizeTotal(known: reclaimable, isComplete: true))
+ return Looked(
+ count: scan.groups.count + scan.folderGroups.count,
+ size: SizeTotal(known: reclaimable, isComplete: true)
+ )
}
}
}
diff --git a/Peel/Model/FrontmostApp.swift b/Peel/Model/FrontmostApp.swift
index d7d79431..fbe366f4 100644
--- a/Peel/Model/FrontmostApp.swift
+++ b/Peel/Model/FrontmostApp.swift
@@ -11,8 +11,13 @@ final class FrontmostApp {
private(set) var bundleIdentifier = NSWorkspace.shared.frontmostApplication?.bundleIdentifier
private init() {
- NSWorkspace.shared.notificationCenter.addObserver(forName: NSWorkspace.didActivateApplicationNotification, object: nil, queue: .main) { note in
- let identifier = (note.userInfo?[NSWorkspace.applicationUserInfoKey] as? NSRunningApplication)?.bundleIdentifier
+ NSWorkspace.shared.notificationCenter.addObserver(
+ forName: NSWorkspace.didActivateApplicationNotification,
+ object: nil,
+ queue: .main
+ ) { note in
+ let identifier = (note.userInfo?[NSWorkspace.applicationUserInfoKey] as? NSRunningApplication)?
+ .bundleIdentifier
MainActor.assumeIsolated { FrontmostApp.shared.bundleIdentifier = identifier }
}
}
diff --git a/Peel/Model/HomeModel.swift b/Peel/Model/HomeModel.swift
index 4f6db6db..b5990dbf 100644
--- a/Peel/Model/HomeModel.swift
+++ b/Peel/Model/HomeModel.swift
@@ -153,7 +153,8 @@ final class HomeModel {
isHelperFromAnotherCopy = helper.isRegisteredByAnotherCopy
notificationStatus = await UNUserNotificationCenter.current().notificationSettings().authorizationStatus
let isFinderExtensionEnabled = await Self.isFinderExtensionEnabled()
- isFinderExtensionFromAnotherCopy = isFinderExtensionEnabled ? false : await Self.finderExtensionRunsFromAnotherCopy()
+ isFinderExtensionFromAnotherCopy =
+ isFinderExtensionEnabled ? false : await Self.finderExtensionRunsFromAnotherCopy()
let fullDisk = await access
needsRelaunchForFullDiskAccess = fullDisk == .missing && hasOpenedFullDiskAccessSettings
@@ -162,7 +163,9 @@ final class HomeModel {
states = [
.fullDiskAccess: state(for: fullDisk),
.helper: helperState,
- .appManagement: state(for: appManagementSeenThisLaunch ?? (appBundles == .unknown ? appManagement : appBundles)),
+ .appManagement: state(
+ for: appManagementSeenThisLaunch ?? (appBundles == .unknown ? appManagement : appBundles)
+ ),
.notifications: notificationStatus == .authorized ? .on : .off,
.finderExtension: isFinderExtensionEnabled ? .on : .off,
.openAtLogin: opensAtLogin ? .on : .off,
diff --git a/Peel/Model/HomebrewLibrary.swift b/Peel/Model/HomebrewLibrary.swift
index 3905e1b2..0aa264f5 100644
--- a/Peel/Model/HomebrewLibrary.swift
+++ b/Peel/Model/HomebrewLibrary.swift
@@ -114,7 +114,8 @@ final class HomebrewLibrary {
/// The packages Homebrew has disabled or deprecated, disabled first, since those can't be installed again.
var retired: [HomebrewPackage] {
let retired = (packages ?? []).filter { $0.retirement != nil }
- return retired.filter { $0.retirement?.stage == .disabled } + retired.filter { $0.retirement?.stage == .deprecated }
+ return retired.filter { $0.retirement?.stage == .disabled }
+ + retired.filter { $0.retirement?.stage == .deprecated }
}
/// What Upgrade All upgrades: the rest are shown as out of date and left alone (`joinsUpgradeAll`), and all of
@@ -249,10 +250,14 @@ final class HomebrewLibrary {
switch command {
case .upgrade(let id):
guard let package = package(id) else { return gone }
- return await following { onOutput throws(Homebrew.CommandFailure) in try await Homebrew.upgrade(package, onOutput: onOutput) }
+ return await following { onOutput throws(Homebrew.CommandFailure) in
+ try await Homebrew.upgrade(package, onOutput: onOutput)
+ }
case .upgradeAll:
let packages = upgradable
- return await following { onOutput throws(Homebrew.CommandFailure) in try await Homebrew.upgrade(packages, onOutput: onOutput) }
+ return await following { onOutput throws(Homebrew.CommandFailure) in
+ try await Homebrew.upgrade(packages, onOutput: onOutput)
+ }
case .uninstall(let id):
guard let package = package(id) else { return gone }
guard let kept = await keptFormulae() else { return keepsNothing }
diff --git a/Peel/Model/InstallerLibrary.swift b/Peel/Model/InstallerLibrary.swift
index c3810eaa..1ea01335 100644
--- a/Peel/Model/InstallerLibrary.swift
+++ b/Peel/Model/InstallerLibrary.swift
@@ -25,7 +25,11 @@ final class InstallerLibrary {
}
func refresh(installedApps: [InstalledApp]) async {
- guard let result = await scanRun.run({ await Installers.scan(installedApps: installedApps, exclusions: ExclusionsStore.shared.exclusions) }) else { return }
+ guard
+ let result = await scanRun.run({
+ await Installers.scan(installedApps: installedApps, exclusions: ExclusionsStore.shared.exclusions)
+ })
+ else { return }
scan = result
selectedURLs.formIntersection(Set(result.items.filter { $0.heldBack?.cannotBeMoved != true }.map(\.url)))
if let selection, result.items(in: selection).isEmpty {
diff --git a/Peel/Model/InventoryExport.swift b/Peel/Model/InventoryExport.swift
index 15eec76d..130c8989 100644
--- a/Peel/Model/InventoryExport.swift
+++ b/Peel/Model/InventoryExport.swift
@@ -25,7 +25,11 @@ enum InventoryExport {
/// Returns nil when the file was written or the user canceled, and the error message otherwise.
@MainActor
- private static func run(format: Inventory.Format, apps: [InstalledApp], homebrew: HomebrewLibrary) async -> String? {
+ private static func run(
+ format: Inventory.Format,
+ apps: [InstalledApp],
+ homebrew: HomebrewLibrary
+ ) async -> String? {
let contents: String
var brewfile: String?
// Homebrew writes the Brewfile, asked only once it has answered, so its definitions are on this Mac.
diff --git a/Peel/Model/PackageLibrary.swift b/Peel/Model/PackageLibrary.swift
index bc36a9ec..34fd0421 100644
--- a/Peel/Model/PackageLibrary.swift
+++ b/Peel/Model/PackageLibrary.swift
@@ -19,7 +19,9 @@ final class PackageLibrary {
}
func refresh() async {
- guard let scan = await scanRun.run({ await PackageReceipts.list(exclusions: ExclusionsStore.shared.exclusions) }) else { return }
+ guard
+ let scan = await scanRun.run({ await PackageReceipts.list(exclusions: ExclusionsStore.shared.exclusions) })
+ else { return }
let result = scan.receipts
receipts = result
couldNotAsk = scan.couldNotAsk
@@ -35,7 +37,10 @@ final class PackageLibrary {
let items = selectedReceipt?.items.filter { selectedURLs.contains($0.url) } ?? []
let privileged = Set(items.filter(\.requiresPrivileges).map(\.url))
let result = await QuitGuard.shared.run {
- let result = await TrashService(exclusions: ExclusionsStore.shared.exclusions).trash(items.map(\.url), usingHelperFor: privileged)
+ let result = await TrashService(exclusions: ExclusionsStore.shared.exclusions).trash(
+ items.map(\.url),
+ usingHelperFor: privileged
+ )
// Written down before the rescan, which can take a while: History is the way back for what just moved.
await record(result)
return result
diff --git a/Peel/Model/PeelNotifications.swift b/Peel/Model/PeelNotifications.swift
index 65ac94a0..ff3f2a51 100644
--- a/Peel/Model/PeelNotifications.swift
+++ b/Peel/Model/PeelNotifications.swift
@@ -76,7 +76,10 @@ final class PeelNotifications: NSObject, UNUserNotificationCenterDelegate {
await MainActor.run { NotificationPresentation.options(whilePeelIsActive: NSApp.isActive) }
}
- nonisolated func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse) async {
+ nonisolated func userNotificationCenter(
+ _ center: UNUserNotificationCenter,
+ didReceive response: UNNotificationResponse
+ ) async {
if let tool = response.notification.request.content.userInfo[Self.toolKey] as? String {
await MainActor.run {
if let tool = Tool(rawValue: tool) {
diff --git a/Peel/Model/PluginLibrary.swift b/Peel/Model/PluginLibrary.swift
index 79076bf2..67ff8911 100644
--- a/Peel/Model/PluginLibrary.swift
+++ b/Peel/Model/PluginLibrary.swift
@@ -16,7 +16,8 @@ final class PluginLibrary {
}
func refresh() async {
- guard let result = await scanRun.run({ await Plugins.scan(exclusions: ExclusionsStore.shared.exclusions) }) else { return }
+ guard let result = await scanRun.run({ await Plugins.scan(exclusions: ExclusionsStore.shared.exclusions) })
+ else { return }
plugins = result
if let selection, !result.contains(where: { $0.id == selection }) {
self.selection = nil
@@ -28,7 +29,10 @@ final class PluginLibrary {
defer { isRemoving = false }
let privileged: Set<URL> = plugin.requiresPrivileges ? [plugin.url] : []
let result = await QuitGuard.shared.run {
- let result = await TrashService(exclusions: ExclusionsStore.shared.exclusions).trash([plugin.url], usingHelperFor: privileged)
+ let result = await TrashService(exclusions: ExclusionsStore.shared.exclusions).trash(
+ [plugin.url],
+ usingHelperFor: privileged
+ )
// Written down before the rescan, which can take a while: History is the way back for what just moved.
await record(result)
return result
diff --git a/Peel/Model/ProjectLibrary.swift b/Peel/Model/ProjectLibrary.swift
index d76a03b3..10952929 100644
--- a/Peel/Model/ProjectLibrary.swift
+++ b/Peel/Model/ProjectLibrary.swift
@@ -60,7 +60,12 @@ final class ProjectLibrary {
wasCutShort = scan.wasCutShort
needsFullDiskAccess = scan.needsFullDiskAccess
let result = Dictionary(grouping: artifacts, by: \.project)
- .map { ProjectGroup(project: $0.key, artifacts: $0.value.sorted { SizeTotal([$0.size]) > SizeTotal([$1.size]) }) }
+ .map {
+ ProjectGroup(
+ project: $0.key,
+ artifacts: $0.value.sorted { SizeTotal([$0.size]) > SizeTotal([$1.size]) }
+ )
+ }
.sorted { $0.total > $1.total }
groups = result
excludedFromBackups = Set(standings.filter { $0.value != .included }.keys)
diff --git a/Peel/Model/QuitBeforeRemoving.swift b/Peel/Model/QuitBeforeRemoving.swift
index a7981dbd..7d93f9be 100644
--- a/Peel/Model/QuitBeforeRemoving.swift
+++ b/Peel/Model/QuitBeforeRemoving.swift
@@ -23,7 +23,8 @@ final class QuitBeforeRemoving {
/// The names of what still runs, for the alerts.
var names: String {
- running.filter { !$0.isTerminated }.map { $0.localizedName ?? $0.bundleIdentifier ?? "" }.formatted(.list(type: .and))
+ running.filter { !$0.isTerminated }.map { $0.localizedName ?? $0.bundleIdentifier ?? "" }
+ .formatted(.list(type: .and))
}
/// Goes on at once when none of `processes` runs, and otherwise asks the person to quit them first.
diff --git a/Peel/Model/RemovalHistoryStore.swift b/Peel/Model/RemovalHistoryStore.swift
index ff52426f..6f1533e8 100644
--- a/Peel/Model/RemovalHistoryStore.swift
+++ b/Peel/Model/RemovalHistoryStore.swift
@@ -34,7 +34,8 @@ nonisolated struct RemovalBatch: Identifiable, Hashable {
}
static func title(of parts: [RemovalPart]) -> String {
- parts.map { title(source: $0.source, key: $0.sourceKey, tool: Tool(rawValue: $0.tool)) }.formatted(.list(type: .and))
+ parts.map { title(source: $0.source, key: $0.sourceKey, tool: Tool(rawValue: $0.tool)) }
+ .formatted(.list(type: .and))
}
static func title(source: String, key: String?, tool: Tool?) -> String {
@@ -186,12 +187,22 @@ final class RemovalHistoryStore {
sizes: [URL: Int64]
) async {
var removal = RemovalInProgress()
- await record(result, part: RemovalPart(source: source, sourceKey: sourceKey, tool: tool.rawValue), sizes: sizes, in: &removal)
+ await record(
+ result,
+ part: RemovalPart(source: source, sourceKey: sourceKey, tool: tool.rawValue),
+ sizes: sizes,
+ in: &removal
+ )
finish(removal)
}
/// Records in History what one part of `removal` moved, and what it refused.
- func record(_ result: TrashResult, part: RemovalPart, sizes: [URL: Int64], in removal: inout RemovalInProgress) async {
+ func record(
+ _ result: TrashResult,
+ part: RemovalPart,
+ sizes: [URL: Int64],
+ in removal: inout RemovalInProgress
+ ) async {
// History first: it is the way back for what just moved, and nothing that follows may keep it unwritten.
if !result.trashed.isEmpty {
let new = part.records(of: result, sizes: sizes, batch: removal.batch)
diff --git a/Peel/Model/RemovalOutcome.swift b/Peel/Model/RemovalOutcome.swift
index 2d19d387..538893ae 100644
--- a/Peel/Model/RemovalOutcome.swift
+++ b/Peel/Model/RemovalOutcome.swift
@@ -28,7 +28,9 @@ final class RemovalOutcome {
privacy resets: [(app: InstalledApp, result: PrivacyReset.Result)] = [],
appsToQuit: [String] = []
) {
- let privacy = PrivacyReset.worthTelling(resets, after: result).map { Privacy(app: $0.app.name, result: $0.result) }
+ let privacy = PrivacyReset.worthTelling(resets, after: result).map {
+ Privacy(app: $0.app.name, result: $0.result)
+ }
guard !result.failures.isEmpty || !privacy.isEmpty || !appsToQuit.isEmpty else { return }
failures = result.failures
movedCount = result.trashed.count
diff --git a/Peel/Model/RemovalPlan.swift b/Peel/Model/RemovalPlan.swift
index 47e72493..8a61c929 100644
--- a/Peel/Model/RemovalPlan.swift
+++ b/Peel/Model/RemovalPlan.swift
@@ -75,7 +75,12 @@ final class RemovalPlan {
/// What a confirmation would ask about now: the selection, with the sizes this scan measured.
var request: RemovalRequest {
RemovalRequest(urls: selectedURLs, sizes: [URL: Int64](measured: selectedURLs.map { url in
- (url, url == app.url ? (isAppMeasured ? appSize : nil) : leftoverSizes[url].flatMap { $0.isMeasured ? $0.size : nil })
+ (
+ url,
+ url == app.url
+ ? (isAppMeasured ? appSize : nil)
+ : leftoverSizes[url].flatMap { $0.isMeasured ? $0.size : nil }
+ )
}))
}
@@ -91,7 +96,12 @@ final class RemovalPlan {
/// The revision of the exclusions the last scan read, nil before the first.
private(set) var exclusionsRevision: Int?
- func refresh(installedApps: [InstalledApp], canUseHelper: Bool, casks: [HomebrewPackage] = [], receipts: Set<String> = []) async {
+ func refresh(
+ installedApps: [InstalledApp],
+ canUseHelper: Bool,
+ casks: [HomebrewPackage] = [],
+ receipts: Set<String> = []
+ ) async {
self.canUseHelper = canUseHelper
let app = app
guard let (result, bundle, revision) = await scanRun.run({
@@ -113,7 +123,10 @@ final class RemovalPlan {
recommendedMovable = result.movable(among: recommended, withApp: true)
reviewMovable = result.movable(among: needsReview, withApp: false)
total = result.movable(among: leftovers, withApp: true).size
- leftoverSizes = Dictionary(leftovers.map { ($0.url, ($0.size, $0.isMeasured)) }, uniquingKeysWith: { first, _ in first })
+ leftoverSizes = Dictionary(
+ leftovers.map { ($0.url, ($0.size, $0.isMeasured)) },
+ uniquingKeysWith: { first, _ in first }
+ )
self.installedApps = installedApps
(vendorUninstaller, systemExtensions) = bundle
selectedURLs = choices.update(selectedURLs, in: result, canUseHelper: self.canUseHelper)
@@ -128,7 +141,9 @@ final class RemovalPlan {
}
@concurrent
- private nonisolated static func look(inside app: InstalledApp) async -> (uninstaller: URL?, systemExtensions: [String]) {
+ private nonisolated static func look(
+ inside app: InstalledApp
+ ) async -> (uninstaller: URL?, systemExtensions: [String]) {
(VendorRemoval.uninstaller(for: app), VendorRemoval.systemExtensions(in: app))
}
@@ -137,7 +152,10 @@ final class RemovalPlan {
let urls = uninstallation?.removalOrder(of: request.urls) ?? []
// These paths are about to hold something else, or nothing, so their cached icons are dropped.
IconCache.forget(urls)
- return await TrashService(exclusions: ExclusionsStore.shared.exclusions).trash(urls, usingHelperFor: uninstallation?.privilegedURLs ?? [])
+ return await TrashService(exclusions: ExclusionsStore.shared.exclusions).trash(
+ urls,
+ usingHelperFor: uninstallation?.privilegedURLs ?? []
+ )
}
/// The app's processes that run now, the helpers it ships included, which quit before any of its files move.
diff --git a/Peel/Model/ResetPlan.swift b/Peel/Model/ResetPlan.swift
index f65d1486..52c37390 100644
--- a/Peel/Model/ResetPlan.swift
+++ b/Peel/Model/ResetPlan.swift
@@ -75,7 +75,11 @@ final class ResetPlan {
guard let result = await scanRun.run({
await AppReset.prepare(app, installedApps: installedApps, exclusions: ExclusionsStore.shared.exclusions)
}) else { return }
- selectedURLs = choices.update(selectedURLs, selectable: Set(result.items.map(\.url)), suggested: result.suggestedSelection)
+ selectedURLs = choices.update(
+ selectedURLs,
+ selectable: Set(result.items.map(\.url)),
+ suggested: result.suggestedSelection
+ )
reset = result
self.installedApps = installedApps
refreshRunningState()
@@ -104,13 +108,17 @@ final class ResetPlan {
couldNotSaveSettings = false
refreshRunningState()
guard !isAppRunning else { return TrashResult() }
- let result = await TrashService(exclusions: ExclusionsStore.shared.exclusions).trash(urls, ownedBy: app.bundleIdentifier)
+ let result = await TrashService(exclusions: ExclusionsStore.shared.exclusions).trash(
+ urls,
+ ownedBy: app.bundleIdentifier
+ )
failures = result.failures
movedCount = result.trashed.count
askedToMove = urls.count
didClearSettings = reset.clearsSettings(moving: result.trashed.map(\.originalURL))
// The app stays installed, so `tccutil` still finds it after the move.
- privacy = resetsPrivacy && canResetPrivacy ? await PrivacyReset.reset(bundleIdentifier: app.bundleIdentifier) : nil
+ privacy =
+ resetsPrivacy && canResetPrivacy ? await PrivacyReset.reset(bundleIdentifier: app.bundleIdentifier) : nil
didReset = true
return result
}
@@ -118,7 +126,11 @@ final class ResetPlan {
/// Puts the settings saved in `backup` back, unless the app is open, which would write its own over them.
func putSettingsBack(from backup: URL) async -> PreferenceBackup.Restored {
await QuitGuard.shared.run {
- await PreferenceBackup.restore(from: backup, of: app.bundleIdentifier, exclusions: ExclusionsStore.shared.exclusions) { @MainActor in
+ await PreferenceBackup.restore(
+ from: backup,
+ of: app.bundleIdentifier,
+ exclusions: ExclusionsStore.shared.exclusions
+ ) { @MainActor in
self.refreshRunningState()
return self.isAppRunning
}
@@ -133,7 +145,12 @@ final class ResetPlan {
}
private var relatedRunningApps: [NSRunningApplication] {
- RunningCopies.belonging(to: app, among: RunningCopies.current, installedApps: installedApps, sharingItsSettings: true)
+ RunningCopies.belonging(
+ to: app,
+ among: RunningCopies.current,
+ installedApps: installedApps,
+ sharingItsSettings: true
+ )
.compactMap { NSRunningApplication(processIdentifier: $0.identifier) }
}
}
diff --git a/Peel/Model/SelfUninstall.swift b/Peel/Model/SelfUninstall.swift
index 77333aa8..0e05939b 100644
--- a/Peel/Model/SelfUninstall.swift
+++ b/Peel/Model/SelfUninstall.swift
@@ -52,7 +52,8 @@ final class SelfUninstall {
return
}
let exclusions = ExclusionsStore.shared.exclusions
- let urls = await Uninstallation.prepare(app, installedApps: installedApps, exclusions: exclusions).unreviewedSelection
+ let urls = await Uninstallation.prepare(app, installedApps: installedApps, exclusions: exclusions)
+ .unreviewedSelection
guard !urls.isEmpty else {
failure = String(localized: "Peel won’t move itself from here: its folder needs an administrator, or Peel is excluded in Settings. Drag it to the Trash in Finder, which asks for an administrator when one is needed.")
return
@@ -76,7 +77,13 @@ final class SelfUninstall {
try? await SMAppService.mainApp.unregister()
let opensAtLogin = [.enabled, .requiresApproval].contains(SMAppService.mainApp.status)
- let result = await SelfRemoval.move(urls, app: bundleURL, folder: PeelFolder.url, using: TrashService(exclusions: exclusions), recording: record)
+ let result = await SelfRemoval.move(
+ urls,
+ app: bundleURL,
+ folder: PeelFolder.url,
+ using: TrashService(exclusions: exclusions),
+ recording: record
+ )
guard result.trashed.contains(where: { $0.originalURL == bundleURL }) else {
work.resume()
let lines = result.failures.map { "\($0.url.abbreviatedPath)\n\($0.reason.explanation)" }
diff --git a/Peel/Model/TerminalLibrary.swift b/Peel/Model/TerminalLibrary.swift
index 03b1db86..12486f73 100644
--- a/Peel/Model/TerminalLibrary.swift
+++ b/Peel/Model/TerminalLibrary.swift
@@ -99,9 +99,14 @@ final class TerminalLibrary {
}
func openTerminal() {
- guard let terminal = NSWorkspace.shared.urlForApplication(withBundleIdentifier: TerminalSettings.identifier) else { return }
+ guard let terminal = NSWorkspace.shared.urlForApplication(withBundleIdentifier: TerminalSettings.identifier)
+ else { return }
if settings.isTerminalOpen {
- NSWorkspace.shared.open([URL.homeDirectory], withApplicationAt: terminal, configuration: NSWorkspace.OpenConfiguration())
+ NSWorkspace.shared.open(
+ [URL.homeDirectory],
+ withApplicationAt: terminal,
+ configuration: NSWorkspace.OpenConfiguration()
+ )
} else {
NSWorkspace.shared.openApplication(at: terminal, configuration: NSWorkspace.OpenConfiguration())
}
diff --git a/Peel/Model/TerminalToolLibrary.swift b/Peel/Model/TerminalToolLibrary.swift
index 8b22127b..a0dba64f 100644
--- a/Peel/Model/TerminalToolLibrary.swift
+++ b/Peel/Model/TerminalToolLibrary.swift
@@ -17,7 +17,9 @@ final class TerminalToolLibrary {
guard prefix != nil, known == nil, await Homebrew.hasLocalDefinitions() else { return }
let names = await Homebrew.formulaNames()
guard !names.isEmpty else { return }
- packages = await Homebrew.formulae(named: Set(TerminalTool.allCases.flatMap(\.formulae)).filter(names.contains).sorted())
+ packages = await Homebrew.formulae(
+ named: Set(TerminalTool.allCases.flatMap(\.formulae)).filter(names.contains).sorted()
+ )
known = names
}
diff --git a/Peel/Model/TweakLibrary.swift b/Peel/Model/TweakLibrary.swift
index d5e7ee50..75684081 100644
--- a/Peel/Model/TweakLibrary.swift
+++ b/Peel/Model/TweakLibrary.swift
@@ -61,7 +61,10 @@ final class TweakLibrary {
/// calls this each time Peel becomes active rather than trusting what it read before.
func refresh() {
store.beginReading()
- states = Dictionary(TweakCatalog.all.map { ($0.id, store.state(of: $0)) }, uniquingKeysWith: { first, _ in first })
+ states = Dictionary(
+ TweakCatalog.all.map { ($0.id, store.state(of: $0)) },
+ uniquingKeysWith: { first, _ in first }
+ )
isSleepDisabled = SleepSetting.isSleepDisabled()
}
diff --git a/Peel/Navigation/ListColumn.swift b/Peel/Navigation/ListColumn.swift
index 51e5d310..e422bd88 100644
--- a/Peel/Navigation/ListColumn.swift
+++ b/Peel/Navigation/ListColumn.swift
@@ -102,11 +102,18 @@ private struct ListColumnDivider: NSViewRepresentable {
private func observe(_ splitView: NSSplitView) {
guard observed !== splitView else { return }
if let observed {
- NotificationCenter.default.removeObserver(self, name: NSSplitView.didResizeSubviewsNotification, object: observed)
+ NotificationCenter.default.removeObserver(
+ self,
+ name: NSSplitView.didResizeSubviewsNotification,
+ object: observed
+ )
}
observed = splitView
NotificationCenter.default.addObserver(
- self, selector: #selector(splitViewResized), name: NSSplitView.didResizeSubviewsNotification, object: splitView
+ self,
+ selector: #selector(splitViewResized),
+ name: NSSplitView.didResizeSubviewsNotification,
+ object: splitView
)
}
@@ -135,7 +142,13 @@ private struct ListColumnDivider: NSViewRepresentable {
let target: CGFloat
if column.isAside {
guard let needs = titleBarNeeds(dividerIndex: split.index) else { return }
- target = max(ListColumn.minimum, min(split.view.bounds.width - ListColumn.besideList, max(column.beforeAside ?? ListColumn.minimum, needs)))
+ target = max(
+ ListColumn.minimum,
+ min(
+ split.view.bounds.width - ListColumn.besideList,
+ max(column.beforeAside ?? ListColumn.minimum, needs)
+ )
+ )
} else if let restore = column.restore {
target = restore
} else {
@@ -156,11 +169,17 @@ private struct ListColumnDivider: NSViewRepresentable {
/// least 160), each toolbar item takes its view plus 8, and the divider sits 4 into its own item.
private func titleBarNeeds(dividerIndex: Int) -> CGFloat? {
guard let items = window?.toolbar?.items,
- let end = items.firstIndex(where: { ($0 as? NSTrackingSeparatorToolbarItem)?.dividerIndex == dividerIndex }),
- let start = items[..<end].lastIndex(where: { $0 is NSTrackingSeparatorToolbarItem }) else { return nil }
+ let end = items.firstIndex(where: {
+ ($0 as? NSTrackingSeparatorToolbarItem)?.dividerIndex == dividerIndex
+ }),
+ let start = items[..<end].lastIndex(where: { $0 is NSTrackingSeparatorToolbarItem })
+ else { return nil }
let itemsWidth = items[(start + 1)..<end].reduce(0) { $0 + ($1.view?.frame.width ?? 0) + 8 }
let words = [NSFont.Weight.semibold, .bold]
- .map { (column.title as NSString).size(withAttributes: [.font: NSFont.systemFont(ofSize: 15, weight: $0)]).width }
+ .map {
+ (column.title as NSString)
+ .size(withAttributes: [.font: NSFont.systemFont(ofSize: 15, weight: $0)]).width
+ }
.max() ?? 0
return ceil(148 + max(160, words + 24) + itemsWidth + 4)
}
@@ -170,8 +189,10 @@ private struct ListColumnDivider: NSViewRepresentable {
private var enclosingSplitView: (view: NSSplitView, item: NSSplitViewItem, index: Int)? {
var view = superview
while let current = view {
- if let splitView = current as? NSSplitView, let controller = splitView.delegate as? NSSplitViewController,
- let index = controller.splitViewItems.firstIndex(where: { isDescendant(of: $0.viewController.view) }) {
+ if let splitView = current as? NSSplitView,
+ let controller = splitView.delegate as? NSSplitViewController,
+ let index = controller.splitViewItems
+ .firstIndex(where: { isDescendant(of: $0.viewController.view) }) {
return (splitView, controller.splitViewItems[index], index)
}
view = current.superview
diff --git a/Peel/Navigation/PeelCommands.swift b/Peel/Navigation/PeelCommands.swift
index ed109c62..068aa4ff 100644
--- a/Peel/Navigation/PeelCommands.swift
+++ b/Peel/Navigation/PeelCommands.swift
@@ -141,7 +141,11 @@ struct PeelCommands: Commands {
} label: {
Text(tool.title)
}
- .keyboardShortcut(index < 9 ? KeyboardShortcut(KeyEquivalent(Character(String(index + 1))), modifiers: .command) : nil)
+ .keyboardShortcut(
+ index < 9
+ ? KeyboardShortcut(KeyEquivalent(Character(String(index + 1))), modifiers: .command)
+ : nil
+ )
.disabled(selectedTool == nil || sheetInFront.isShowing)
}
Divider()
diff --git a/Peel/Navigation/PeelIntents.swift b/Peel/Navigation/PeelIntents.swift
index 5d987293..8e6f8157 100644
--- a/Peel/Navigation/PeelIntents.swift
+++ b/Peel/Navigation/PeelIntents.swift
@@ -119,12 +119,16 @@ struct InstalledAppEntity: AppEntity {
struct InstalledAppQuery: EntityStringQuery {
func entities(for identifiers: [String]) async throws -> [InstalledAppEntity] {
let wanted = Set(identifiers)
- return await AppCatalog.installedApps().filter { wanted.contains($0.bundleIdentifier) }.map(InstalledAppEntity.init)
+ return await AppCatalog.installedApps().filter { wanted.contains($0.bundleIdentifier) }
+ .map(InstalledAppEntity.init)
}
func entities(matching string: String) async throws -> [InstalledAppEntity] {
await AppCatalog.installedApps()
- .filter { app in app.names.contains { SearchText.matches($0, string) } || SearchText.matches(app.bundleIdentifier, string) }
+ .filter { app in
+ app.names.contains { SearchText.matches($0, string) }
+ || SearchText.matches(app.bundleIdentifier, string)
+ }
.map(InstalledAppEntity.init)
}
diff --git a/Peel/Navigation/SidebarFocus.swift b/Peel/Navigation/SidebarFocus.swift
index 0370456c..fe336735 100644
--- a/Peel/Navigation/SidebarFocus.swift
+++ b/Peel/Navigation/SidebarFocus.swift
@@ -46,7 +46,9 @@ private struct ListFocus: NSViewRepresentable {
}
private func takeFocusIfNothingHasIt() {
- guard let window, window.firstResponder === window, let list = list(in: enclosingSplitViewItem?.viewController.view) else { return }
+ guard let window, window.firstResponder === window,
+ let list = list(in: enclosingSplitViewItem?.viewController.view)
+ else { return }
window.makeFirstResponder(list)
}
diff --git a/Peel/Navigation/ToolSidebar.swift b/Peel/Navigation/ToolSidebar.swift
index 486b7c23..9e78f3c7 100644
--- a/Peel/Navigation/ToolSidebar.swift
+++ b/Peel/Navigation/ToolSidebar.swift
@@ -40,7 +40,9 @@ struct ToolSidebar: View {
@State private var scrollerRoom = Self.currentScrollerRoom
private static var currentScrollerRoom: CGFloat {
- NSScroller.preferredScrollerStyle == .legacy ? NSScroller.scrollerWidth(for: .regular, scrollerStyle: .legacy) : 0
+ NSScroller.preferredScrollerStyle == .legacy
+ ? NSScroller.scrollerWidth(for: .regular, scrollerStyle: .legacy)
+ : 0
}
/// One selection for the whole sidebar, mapped onto the two bindings behind it, `tool` and `page`. It is built
@@ -73,7 +75,9 @@ struct ToolSidebar: View {
}
.safeAreaBar(edge: .top, spacing: 0) { mascot }
.takesFocusWhenNothingHasIt()
- .onReceive(NotificationCenter.default.publisher(for: NSScroller.preferredScrollerStyleDidChangeNotification)) { _ in
+ .onReceive(
+ NotificationCenter.default.publisher(for: NSScroller.preferredScrollerStyleDidChangeNotification)
+ ) { _ in
scrollerRoom = Self.currentScrollerRoom
fitWidth()
}
diff --git a/Peel/PeelApp.swift b/Peel/PeelApp.swift
index bed91b57..e4f243c2 100644
--- a/Peel/PeelApp.swift
+++ b/Peel/PeelApp.swift
@@ -71,7 +71,9 @@ struct PeelApp: App {
_notifications = State(initialValue: notifications)
let (library, history, outcome) = (AppLibrary(), RemovalHistoryStore(), RemovalOutcome())
- let (orphans, space, developer, projects) = (OrphanLibrary(), SpaceLibrary(), DeveloperLibrary(), ProjectLibrary())
+ let (orphans, space, developer, projects) = (
+ OrphanLibrary(), SpaceLibrary(), DeveloperLibrary(), ProjectLibrary()
+ )
let (installers, duplicates, fileSearch) = (InstallerLibrary(), DuplicateLibrary(), FileSearchLibrary())
_library = State(initialValue: library)
_history = State(initialValue: history)
diff --git a/Peel/TerminalExport.swift b/Peel/TerminalExport.swift
index 86351ac1..d5742b76 100644
--- a/Peel/TerminalExport.swift
+++ b/Peel/TerminalExport.swift
@@ -14,7 +14,11 @@ enum TerminalExport {
try FileManager.default.createDirectory(at: renders, withIntermediateDirectories: true)
try FileManager.default.createDirectory(at: prompts, withIntermediateDirectories: true)
for theme in TerminalThemeCatalog.all {
- let profile = try PropertyListSerialization.data(fromPropertyList: TerminalProfile.settings(for: theme), format: .xml, options: 0)
+ let profile = try PropertyListSerialization.data(
+ fromPropertyList: TerminalProfile.settings(for: theme),
+ format: .xml,
+ options: 0
+ )
try profile.write(to: themes.appending(path: "\(theme.profileName).terminal"))
try render(TerminalSession(theme: theme).frame(width: 300), to: renders.appending(path: "\(theme.name).png"))
}
@@ -33,7 +37,9 @@ enum TerminalExport {
private static func render(_ view: some View, to url: URL) throws {
let renderer = ImageRenderer(content: view.environment(\.colorScheme, .dark))
renderer.scale = 4
- guard let image = renderer.cgImage, let png = NSBitmapImageRep(cgImage: image).representation(using: .png, properties: [:]) else {
+ guard let image = renderer.cgImage,
+ let png = NSBitmapImageRep(cgImage: image).representation(using: .png, properties: [:])
+ else {
throw CocoaError(.fileWriteUnknown)
}
try png.write(to: url)
diff --git a/Peel/Views/AppDetailView.swift b/Peel/Views/AppDetailView.swift
index 08e96604..54ff6bd8 100644
--- a/Peel/Views/AppDetailView.swift
+++ b/Peel/Views/AppDetailView.swift
@@ -200,7 +200,12 @@ struct AppDetailView: View {
.toolbar {
ToolbarItem {
RescanButton(isRunning: $isRescanning, isDisabled: plan.isRemoving, scan: plan.scanRun) {
- await plan.refresh(installedApps: library.apps, canUseHelper: helper.canAct, casks: homebrew.caskEvidence, receipts: homebrew.receipts)
+ await plan.refresh(
+ installedApps: library.apps,
+ canUseHelper: helper.canAct,
+ casks: homebrew.caskEvidence,
+ receipts: homebrew.receipts
+ )
// In a task of its own, so the page isn't dimmed during the update check, which can take
// half a minute. The badge in the header shows that the check is running.
let app = plan.app
@@ -344,7 +349,12 @@ struct AppDetailView: View {
/// one the tables are out of date. A scan asked for while the question is up or a removal runs waits for them.
private func rescan() async {
guard plan.question.mayScan() else { return }
- await plan.refresh(installedApps: library.apps, canUseHelper: helper.canAct, casks: homebrew.caskEvidence, receipts: homebrew.receipts)
+ await plan.refresh(
+ installedApps: library.apps,
+ canUseHelper: helper.canAct,
+ casks: homebrew.caskEvidence,
+ receipts: homebrew.receipts
+ )
}
private func row(for leftover: Leftover) -> some View {
@@ -441,7 +451,11 @@ struct AppDetailView: View {
if removesDockTile, result.trashed.contains(where: { $0.originalURL == plan.app.url }) {
_ = await DockTiles().takeOut([plan.app.url])
}
- if let state = AppManagement.state(after: result, appBundles: [plan.app.url], movedByTheHelper: plan.privilegedURLs) {
+ if let state = AppManagement.state(
+ after: result,
+ appBundles: [plan.app.url],
+ movedByTheHelper: plan.privilegedURLs
+ ) {
home.record(appManagement: state)
}
await history.record(result, tool: .applications, source: plan.app.name, sizes: request.sizes)
@@ -451,7 +465,12 @@ struct AppDetailView: View {
if result.trashed.contains(where: { $0.originalURL == plan.app.url }) {
await library.checkAgain(await library.refresh())
} else {
- await plan.refresh(installedApps: library.apps, canUseHelper: helper.canAct, casks: homebrew.caskEvidence, receipts: homebrew.receipts)
+ await plan.refresh(
+ installedApps: library.apps,
+ canUseHelper: helper.canAct,
+ casks: homebrew.caskEvidence,
+ receipts: homebrew.receipts
+ )
}
}
}
diff --git a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
index a2d70d9e..954ddc86 100644
--- a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
+++ b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
@@ -194,7 +194,8 @@ struct BackgroundItemDetailView: View {
/// Whether this item needs administrator access while the helper can't act. Never true for Peel's own helper
/// or a job under one of macOS's labels: neither offers an action, so the helper would change nothing.
private var needsHelper: Bool {
- !item.isPeelsHelper && !item.usesALabelOfMacOS && (item.requiresPrivileges || item.removalRequiresPrivileges) && !helper.canAct
+ !item.isPeelsHelper && !item.usesALabelOfMacOS && (item.requiresPrivileges || item.removalRequiresPrivileges)
+ && !helper.canAct
}
private var finderURL: URL? {
@@ -331,7 +332,10 @@ struct BackgroundItemDetailView: View {
isConfirmingTrash = true
}
.buttonStyle(.borderedProminent)
- .disabled(isBusy || item.removalRequiresPrivileges && !helper.canAct || !exclusions.exclusions.isKnown || history.isUnreadable)
+ .disabled(
+ isBusy || item.removalRequiresPrivileges && !helper.canAct || !exclusions.exclusions.isKnown
+ || history.isUnreadable
+ )
}
}
diff --git a/Peel/Views/BackgroundItems/BackgroundItemList.swift b/Peel/Views/BackgroundItems/BackgroundItemList.swift
index b55118ea..2be69b55 100644
--- a/Peel/Views/BackgroundItems/BackgroundItemList.swift
+++ b/Peel/Views/BackgroundItems/BackgroundItemList.swift
@@ -29,17 +29,27 @@ struct BackgroundItemList: View {
.columnSearch(text: $searchText, prompt: "Search Background Items", when: backgroundItems.items?.isEmpty == false)
.fadesInColumn(whenRowsChange: backgroundItems.items?.map(\.id))
.navigationTitle(Text(Tool.backgroundItems.title))
- .announcesScan(backgroundItems.isScanning, found: backgroundItems.summary, wasStopped: backgroundItems.scanRun.wasStopped)
+ .announcesScan(
+ backgroundItems.isScanning,
+ found: backgroundItems.summary,
+ wasStopped: backgroundItems.scanRun.wasStopped
+ )
.toolbar {
ToolbarItem {
- RescanButton(isRunning: $isRescanning, isDisabled: !library.hasLoaded || !backgroundItems.runningActionItemIDs.isEmpty, scan: backgroundItems.scanRun) {
+ RescanButton(
+ isRunning: $isRescanning,
+ isDisabled: !library.hasLoaded || !backgroundItems.runningActionItemIDs.isEmpty,
+ scan: backgroundItems.scanRun
+ ) {
await backgroundItems.refresh(installedApps: library.apps)
}
}
}
// The first scan waits for the installed apps, which it needs to trace each item to the app that owns it.
.task(id: library.hasLoaded) {
- guard library.hasLoaded, backgroundItems.items == nil, !backgroundItems.isScanning, !backgroundItems.scanRun.wasStopped else { return }
+ guard library.hasLoaded, backgroundItems.items == nil, !backgroundItems.isScanning,
+ !backgroundItems.scanRun.wasStopped
+ else { return }
await backgroundItems.refresh(installedApps: library.apps)
}
.rescanOnExclusionChange("BackgroundItemList") { await backgroundItems.refresh(installedApps: library.apps) }
@@ -113,7 +123,8 @@ struct BackgroundItemList: View {
let items = backgroundItems.items ?? []
guard !searchText.isEmpty else { return items }
return items.filter { item in
- SearchText.matches(item.label, searchText) || ownerName(of: item).map { SearchText.matches($0, searchText) } == true
+ SearchText.matches(item.label, searchText)
+ || ownerName(of: item).map { SearchText.matches($0, searchText) } == true
}
}
diff --git a/Peel/Views/DetailPlaceholder.swift b/Peel/Views/DetailPlaceholder.swift
index 050216e2..9c8e4aaf 100644
--- a/Peel/Views/DetailPlaceholder.swift
+++ b/Peel/Views/DetailPlaceholder.swift
@@ -52,6 +52,11 @@ struct DetailPlaceholder: View {
extension DetailPlaceholder {
/// A tool's own pane: its name, what it holds, and the instruction only when there is something to choose.
init(tool: Tool, summary: AttributedString?, instruction: LocalizedStringResource) {
- self.init(title: tool.title, systemImage: tool.systemImage, description: summary == nil ? nil : instruction, summary: summary.map { Text($0) })
+ self.init(
+ title: tool.title,
+ systemImage: tool.systemImage,
+ description: summary == nil ? nil : instruction,
+ summary: summary.map { Text($0) }
+ )
}
}
diff --git a/Peel/Views/Developer/DeveloperDetailView.swift b/Peel/Views/Developer/DeveloperDetailView.swift
index 35a90f67..9f76cb00 100644
--- a/Peel/Views/Developer/DeveloperDetailView.swift
+++ b/Peel/Views/Developer/DeveloperDetailView.swift
@@ -32,7 +32,11 @@ struct DeveloperDetailView: View {
}
.dimmedWhileBusy(developer.isScanning)
.safeAreaBar(edge: .bottom) {
- RemovalBar(page: Tool.developer.page(environment.id), isScanning: developer.isScanning, scan: developer.scanRun)
+ RemovalBar(
+ page: Tool.developer.page(environment.id),
+ isScanning: developer.isScanning,
+ scan: developer.scanRun
+ )
}
.fadesInColumn(whenRowsChange: environment.locations.map(\.id))
.navigationTitle(environment.name)
@@ -71,7 +75,11 @@ struct DeveloperDetailView: View {
private func warning(for location: DeveloperEnvironment.Location) -> String? {
if location.size == nil {
- return String(localized: location.couldNotBeRead ? HoldBack.couldNotBeRead.explanation : HoldBack.notMeasured.explanation)
+ return String(
+ localized: location.couldNotBeRead
+ ? HoldBack.couldNotBeRead.explanation
+ : HoldBack.notMeasured.explanation
+ )
}
if !location.isTheTools {
return String(localized: "Not selected: nothing shows that \(environment.name) made this folder.")
diff --git a/Peel/Views/Duplicates/DuplicateScanForm.swift b/Peel/Views/Duplicates/DuplicateScanForm.swift
index 14492dcb..6a7f7c1a 100644
--- a/Peel/Views/Duplicates/DuplicateScanForm.swift
+++ b/Peel/Views/Duplicates/DuplicateScanForm.swift
@@ -63,7 +63,11 @@ struct DuplicateScanForm: View {
.frame(width: 420)
// The popover grows with the folders listed up to this height, and the list scrolls past it.
.frame(maxHeight: 460)
- .fileImporter(isPresented: $isChoosingFolders, allowedContentTypes: [.folder], allowsMultipleSelection: true) { result in
+ .fileImporter(
+ isPresented: $isChoosingFolders,
+ allowedContentTypes: [.folder],
+ allowsMultipleSelection: true
+ ) { result in
guard case .success(let urls) = result else { return }
rejectedFolders = duplicates.add(urls)
}
diff --git a/Peel/Views/Duplicates/DuplicateStatusViews.swift b/Peel/Views/Duplicates/DuplicateStatusViews.swift
index a081702f..73cd56d1 100644
--- a/Peel/Views/Duplicates/DuplicateStatusViews.swift
+++ b/Peel/Views/Duplicates/DuplicateStatusViews.swift
@@ -119,7 +119,9 @@ extension DuplicateRemovalBar {
var groupsAffected: Int {
let scan = duplicates.scan
return (scan?.groups ?? []).count { group in group.files.contains { duplicates.selectedURLs.contains($0.url) } }
- + (scan?.folderGroups ?? []).count { group in group.folders.contains { duplicates.selectedFolders.contains($0.url) } }
+ + (scan?.folderGroups ?? []).count { group in
+ group.folders.contains { duplicates.selectedFolders.contains($0.url) }
+ }
}
}
diff --git a/Peel/Views/Extensions/ExtensionText.swift b/Peel/Views/Extensions/ExtensionText.swift
index 63434f0c..9bd70858 100644
--- a/Peel/Views/Extensions/ExtensionText.swift
+++ b/Peel/Views/Extensions/ExtensionText.swift
@@ -16,7 +16,8 @@ extension AppExtension {
/// purpose: Xcode's string extraction can miss the words of a switch expression assigned to a local `let`, and
/// those words would then stay English in every language.
private enum ExtensionPoint {
- case finder, share, widgets, quickLook, safari, shortcuts, notifications, spotlight, photos, messages, network, audio, quickActions
+ case finder, share, widgets, quickLook, safari, shortcuts, notifications, spotlight, photos, messages, network,
+ audio, quickActions
init?(_ identifier: String) {
switch identifier {
diff --git a/Peel/Views/FlowLayout.swift b/Peel/Views/FlowLayout.swift
index 03efbafc..dd6e4f78 100644
--- a/Peel/Views/FlowLayout.swift
+++ b/Peel/Views/FlowLayout.swift
@@ -14,7 +14,10 @@ struct FlowLayout: Layout {
func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) {
let arrangement = arrange(subviews, in: bounds.width)
for (subview, frame) in zip(subviews, arrangement.frames) {
- subview.place(at: CGPoint(x: bounds.minX + frame.minX, y: bounds.minY + frame.minY), proposal: ProposedViewSize(frame.size))
+ subview.place(
+ at: CGPoint(x: bounds.minX + frame.minX, y: bounds.minY + frame.minY),
+ proposal: ProposedViewSize(frame.size)
+ )
}
}
diff --git a/Peel/Views/History/HistoryDetailView.swift b/Peel/Views/History/HistoryDetailView.swift
index 789df4e3..eb5fba28 100644
--- a/Peel/Views/History/HistoryDetailView.swift
+++ b/Peel/Views/History/HistoryDetailView.swift
@@ -46,7 +46,8 @@ struct HistoryDetailView: View {
RestoreBar(
count: selectedCount,
isRestoring: history.isRestoring,
- isEnabled: selectedCount > 0 && !history.isRestoring && exclusions.exclusions.isKnown && !history.isUnreadable
+ isEnabled: selectedCount > 0 && !history.isRestoring && exclusions.exclusions.isKnown
+ && !history.isUnreadable
) {
guard let standing else { return }
let selected = standing.selected(among: batch.records, in: history.selectedIDs)
diff --git a/Peel/Views/History/HistoryList.swift b/Peel/Views/History/HistoryList.swift
index 1b695474..f04126dc 100644
--- a/Peel/Views/History/HistoryList.swift
+++ b/Peel/Views/History/HistoryList.swift
@@ -100,7 +100,11 @@ struct HistoryList: View {
return
}
guard let batches = await SearchText.matching(searchText, among: history.batches, keys: history.searchKeys),
- let refusals = await SearchText.matching(searchText, among: history.refusalBatches, keys: history.refusalSearchKeys)
+ let refusals = await SearchText.matching(
+ searchText,
+ among: history.refusalBatches,
+ keys: history.refusalSearchKeys
+ )
else { return }
found = Found(batches: batches, refusals: refusals)
}
diff --git a/Peel/Views/History/RefusalDetailView.swift b/Peel/Views/History/RefusalDetailView.swift
index fe889c3f..625fe891 100644
--- a/Peel/Views/History/RefusalDetailView.swift
+++ b/Peel/Views/History/RefusalDetailView.swift
@@ -22,7 +22,11 @@ struct RefusalDetailView: View {
Section {
ForEach(Array(batch.records.enumerated()), id: \.element.id) { index, record in
- RefusalRecordRow(record: record, isExcluded: exclusions.exclusions.excludes(record.url), isFirst: index == 0)
+ RefusalRecordRow(
+ record: record,
+ isExcluded: exclusions.exclusions.excludes(record.url),
+ isFirst: index == 0
+ )
}
.listRowSeparator(.hidden)
} header: {
diff --git a/Peel/Views/Home/HomeView.swift b/Peel/Views/Home/HomeView.swift
index 0b873a33..5646864d 100644
--- a/Peel/Views/Home/HomeView.swift
+++ b/Peel/Views/Home/HomeView.swift
@@ -112,7 +112,17 @@ struct HomeContent: View {
/// removal is shown only in the menu bar panel, since a fourth sticker doesn't fit the column.
private var totals: some View {
HStack(spacing: 10) {
- DeviceSticker(value: stats.bytesFreed.text, amount: Double(stats.bytesFreed.known), label: "Moved to Trash", fill: Album.orange, ink: Album.onOrange, labelOpacity: 1, width: 86, radius: 16, angle: -3)
+ DeviceSticker(
+ value: stats.bytesFreed.text,
+ amount: Double(stats.bytesFreed.known),
+ label: "Moved to Trash",
+ fill: Album.orange,
+ ink: Album.onOrange,
+ labelOpacity: 1,
+ width: 86,
+ radius: 16,
+ angle: -3
+ )
DeviceSticker(
value: stats.appsRemoved.shortCount,
amount: Double(stats.appsRemoved),
@@ -132,9 +142,33 @@ struct HomeContent: View {
private func specs(_ device: DeviceInfo) -> some View {
HStack(spacing: 12) {
- DeviceSticker(value: device.chipName, label: "Chip", fill: Album.charcoal, ink: .white, width: 62, radius: 12, angle: -4)
- DeviceSticker(value: device.memory.formatted(.byteCount(style: .memory)), label: "Memory", fill: Album.cream, ink: Album.charcoal, width: 66, radius: 33, angle: 3)
- DeviceSticker(value: device.systemVersion, label: "macOS", fill: Album.quietFill, ink: Album.ink, width: 76, radius: 31, angle: -1.5)
+ DeviceSticker(
+ value: device.chipName,
+ label: "Chip",
+ fill: Album.charcoal,
+ ink: .white,
+ width: 62,
+ radius: 12,
+ angle: -4
+ )
+ DeviceSticker(
+ value: device.memory.formatted(.byteCount(style: .memory)),
+ label: "Memory",
+ fill: Album.cream,
+ ink: Album.charcoal,
+ width: 66,
+ radius: 33,
+ angle: 3
+ )
+ DeviceSticker(
+ value: device.systemVersion,
+ label: "macOS",
+ fill: Album.quietFill,
+ ink: Album.ink,
+ width: 76,
+ radius: 31,
+ angle: -1.5
+ )
}
.fixedSize(horizontal: false, vertical: true)
}
diff --git a/Peel/Views/Homebrew/HomebrewList.swift b/Peel/Views/Homebrew/HomebrewList.swift
index 8130a4be..33c341f2 100644
--- a/Peel/Views/Homebrew/HomebrewList.swift
+++ b/Peel/Views/Homebrew/HomebrewList.swift
@@ -46,7 +46,11 @@ struct HomebrewList: View {
)
.toolbar {
ToolbarItem {
- RescanButton(isRunning: $isRescanning, isDisabled: !homebrew.isInstalled || homebrew.runningCommand != nil, scan: homebrew.scanRun) {
+ RescanButton(
+ isRunning: $isRescanning,
+ isDisabled: !homebrew.isInstalled || homebrew.runningCommand != nil,
+ scan: homebrew.scanRun
+ ) {
await homebrew.refresh(includingReclaimable: true)
}
}
@@ -74,7 +78,9 @@ struct HomebrewList: View {
.task {
// Only this page shows what Clean Up would free, so the figure is asked for here, and only while
// it's unknown: `brew cleanup --dry-run` has to walk the cache and the Cellar to work it out.
- guard !homebrew.isScanning, !homebrew.scanRun.wasStopped, homebrew.packages == nil || homebrew.reclaimable == nil else { return }
+ guard !homebrew.isScanning, !homebrew.scanRun.wasStopped,
+ homebrew.packages == nil || homebrew.reclaimable == nil
+ else { return }
await homebrew.refresh(includingReclaimable: true)
}
}
@@ -112,7 +118,9 @@ struct HomebrewList: View {
if overrides.contains(.cleansUp) { sentences.append(String(localized: HomebrewLibrary.cleansUp)) }
if overrides.contains(.sendsAnalytics) { sentences.append(String(localized: "Homebrew sends its makers analytics whenever Peel runs it.")) }
if overrides.contains(.updatesItself) { sentences.append(String(localized: "Homebrew may download its list of packages when Peel only asks about them.")) }
- let prefix = homebrew.installation?.prefix ?? Homebrew.executableURL?.deletingLastPathComponent().deletingLastPathComponent()
+ let prefix =
+ homebrew.installation?.prefix
+ ?? Homebrew.executableURL?.deletingLastPathComponent().deletingLastPathComponent()
let folder = (prefix?.path(percentEncoded: false) ?? "") + "/etc/homebrew"
sentences.append(String(localized: "A brew.env file sets this, in /etc/homebrew, in \(folder), or in ~/.homebrew."))
// A line each, since Chinese and Japanese put no space between sentences.
@@ -127,7 +135,9 @@ struct HomebrewList: View {
.textSelection(.enabled)
}
LabeledContent("Location") {
- let location = homebrew.installation?.prefix.path(percentEncoded: false) ?? String(localized: "Unknown (Homebrew location)", defaultValue: "Unknown")
+ let location =
+ homebrew.installation?.prefix.path(percentEncoded: false)
+ ?? String(localized: "Unknown (Homebrew location)", defaultValue: "Unknown")
Text(verbatim: location)
.font(.callout.monospaced())
.textSelection(.enabled)
@@ -294,7 +304,9 @@ struct HomebrewList: View {
Section {
Notice(
title: Text("Homebrew didn’t say what is installed"),
- detail: Text(verbatim: FixedSentence.translated(problem.trimmingCharacters(in: .whitespacesAndNewlines))),
+ detail: Text(
+ verbatim: FixedSentence.translated(problem.trimmingCharacters(in: .whitespacesAndNewlines))
+ ),
kind: .note
) {}
.listRowSeparator(.hidden)
@@ -499,7 +511,8 @@ struct HomebrewList: View {
let packages = homebrew.packages ?? []
guard !searchText.isEmpty else { return packages }
return packages.filter {
- SearchText.matches($0.name, searchText) || $0.summary.map { summary in SearchText.matches(summary, searchText) } == true
+ SearchText.matches($0.name, searchText)
+ || $0.summary.map { summary in SearchText.matches(summary, searchText) } == true
}
}
}
diff --git a/Peel/Views/Installers/InstallerDetailView.swift b/Peel/Views/Installers/InstallerDetailView.swift
index 6b5b75b9..a59e8b39 100644
--- a/Peel/Views/Installers/InstallerDetailView.swift
+++ b/Peel/Views/Installers/InstallerDetailView.swift
@@ -46,7 +46,9 @@ struct InstallerDetailView: View {
heading(kind.title, kind.explanation)
} actions: {
SelectAllButton(
- selectable: rows.filter { !$0.isReadOnly && $0.heldBack == nil && !($0.requiresPrivileges && !helper.canAct) }.map(\.url),
+ selectable: rows.filter {
+ !$0.isReadOnly && $0.heldBack == nil && !($0.requiresPrivileges && !helper.canAct)
+ }.map(\.url),
rows: rows.map(\.url),
selection: Bindable(installers).selectedURLs
)
@@ -76,7 +78,11 @@ struct InstallerDetailView: View {
.dimmedWhileBusy(installers.isScanning)
.safeAreaBar(edge: .bottom) {
if kind != .deviceBackup {
- RemovalBar(page: Tool.installers.page(kind.rawValue), isScanning: installers.isScanning, scan: installers.scanRun)
+ RemovalBar(
+ page: Tool.installers.page(kind.rawValue),
+ isScanning: installers.isScanning,
+ scan: installers.scanRun
+ )
}
}
.fadesInColumn(whenRowsChange: items.map(\.id))
diff --git a/Peel/Views/Installers/InstallerList.swift b/Peel/Views/Installers/InstallerList.swift
index 6d149b34..5c69ad0e 100644
--- a/Peel/Views/Installers/InstallerList.swift
+++ b/Peel/Views/Installers/InstallerList.swift
@@ -62,13 +62,18 @@ struct InstallerList: View {
)
.toolbar {
ToolbarItem {
- RescanButton(isRunning: $isRescanning, isDisabled: !library.hasLoaded || installers.isRemoving, scan: installers.scanRun) {
+ RescanButton(
+ isRunning: $isRescanning,
+ isDisabled: !library.hasLoaded || installers.isRemoving,
+ scan: installers.scanRun
+ ) {
await installers.refresh(installedApps: library.apps)
}
}
}
.task(id: library.hasLoaded) {
- guard library.hasLoaded, installers.scan == nil, !installers.isScanning, !installers.scanRun.wasStopped else { return }
+ guard library.hasLoaded, installers.scan == nil, !installers.isScanning, !installers.scanRun.wasStopped
+ else { return }
await installers.refresh(installedApps: library.apps)
}
.rescanOnExclusionChange("InstallerList") { await installers.refresh(installedApps: library.apps) }
diff --git a/Peel/Views/Intel/IntelDetailView.swift b/Peel/Views/Intel/IntelDetailView.swift
index 1cb8976d..49d00b51 100644
--- a/Peel/Views/Intel/IntelDetailView.swift
+++ b/Peel/Views/Intel/IntelDetailView.swift
@@ -76,7 +76,11 @@ struct IntelDetailView: View {
}
if let app, let status = library.shownUpdateStatus(of: app) {
LabeledContent("Updates") {
- UpdateStatusBadge(app: app, status: status, isChecking: library.appsCheckingForUpdates.contains(app.id))
+ UpdateStatusBadge(
+ app: app,
+ status: status,
+ isChecking: library.appsCheckingForUpdates.contains(app.id)
+ )
}
}
} header: {
diff --git a/Peel/Views/Intel/IntelList.swift b/Peel/Views/Intel/IntelList.swift
index 2e4d3ad4..ed7a49e7 100644
--- a/Peel/Views/Intel/IntelList.swift
+++ b/Peel/Views/Intel/IntelList.swift
@@ -61,7 +61,9 @@ struct IntelList: View {
}
}
.task(id: library.revision) {
- guard library.hasLoaded, intel.scannedRevision != library.revision, !(intel.scan == nil && intel.scanRun.wasStopped) else { return }
+ guard library.hasLoaded, intel.scannedRevision != library.revision,
+ !(intel.scan == nil && intel.scanRun.wasStopped)
+ else { return }
await scan()
}
.rescanOnExclusionChange("IntelList") { await scan() }
diff --git a/Peel/Views/ItemMenu.swift b/Peel/Views/ItemMenu.swift
index a6404193..ef9240a0 100644
--- a/Peel/Views/ItemMenu.swift
+++ b/Peel/Views/ItemMenu.swift
@@ -39,6 +39,9 @@ struct ItemMenu: View {
}
}
}
- .disabled(isExcluded || ExclusionsStore.shared.exclusions.isUnreadable || (appIdentifier == nil && ExclusionsStore.isTooBroad(url)))
+ .disabled(
+ isExcluded || ExclusionsStore.shared.exclusions.isUnreadable
+ || (appIdentifier == nil && ExclusionsStore.isTooBroad(url))
+ )
}
}
diff --git a/Peel/Views/MenuBarPanel.swift b/Peel/Views/MenuBarPanel.swift
index de26da52..831d63d0 100644
--- a/Peel/Views/MenuBarPanel.swift
+++ b/Peel/Views/MenuBarPanel.swift
@@ -137,7 +137,12 @@ struct MenuBarPanel: View {
.motion(.settle, .movement, value: waiting.count)
}
- private func row(_ symbol: String, _ label: LocalizedStringResource, _ value: String, amount: some BinaryInteger) -> some View {
+ private func row(
+ _ symbol: String,
+ _ label: LocalizedStringResource,
+ _ value: String,
+ amount: some BinaryInteger
+ ) -> some View {
rowContent(symbol, Text(label), value, amount: amount, isAccented: false)
}
diff --git a/Peel/Views/MultipleAppsView.swift b/Peel/Views/MultipleAppsView.swift
index d52f6107..a1652306 100644
--- a/Peel/Views/MultipleAppsView.swift
+++ b/Peel/Views/MultipleAppsView.swift
@@ -74,7 +74,10 @@ struct MultipleAppsView: View {
}
}
- if plan.apps.contains(where: { PrivacyReset.isAllowed(bundleIdentifier: $0.bundleIdentifier) && !plan.appsInTheTrash.contains($0.url) }) {
+ if plan.apps.contains(where: {
+ PrivacyReset.isAllowed(bundleIdentifier: $0.bundleIdentifier)
+ && !plan.appsInTheTrash.contains($0.url)
+ }) {
PrivacyResetRow(isOn: $resetsPrivacy, detail: PrivacyResetRow.beforeTheMove)
}
if !appsInTheDock.isEmpty {
@@ -105,7 +108,12 @@ struct MultipleAppsView: View {
.toolbar {
ToolbarItem {
RescanButton(isRunning: $isRescanning, isDisabled: plan.isRemoving, scan: plan.scanRun) {
- await plan.refresh(installedApps: library.apps, canUseHelper: helper.canAct, casks: homebrew.caskEvidence, receipts: homebrew.receipts)
+ await plan.refresh(
+ installedApps: library.apps,
+ canUseHelper: helper.canAct,
+ casks: homebrew.caskEvidence,
+ receipts: homebrew.receipts
+ )
}
}
}
@@ -153,7 +161,12 @@ struct MultipleAppsView: View {
/// A scan asked for while the question is up or a removal runs waits for them.
private func rescan() async {
guard plan.question.mayScan() else { return }
- await plan.refresh(installedApps: library.apps, canUseHelper: helper.canAct, casks: homebrew.caskEvidence, receipts: homebrew.receipts)
+ await plan.refresh(
+ installedApps: library.apps,
+ canUseHelper: helper.canAct,
+ casks: homebrew.caskEvidence,
+ receipts: homebrew.receipts
+ )
}
private var phase: ScanPhase {
@@ -197,7 +210,8 @@ struct MultipleAppsView: View {
isMeasured: item.isMeasured,
isLocked: item.requiresPrivileges && !helper.canAct,
isExcluded: item.isApplication && item.isExcluded,
- isLeftAlone: item.match?.heldBack?.cannotBeMoved == true || item.isBeyondTheHelper || (item.isApplication && item.isKeptByMacOS)
+ isLeftAlone: item.match?.heldBack?.cannotBeMoved == true || item.isBeyondTheHelper
+ || (item.isApplication && item.isKeptByMacOS)
|| item.isPeels || item.isInTheTrash || item.enclosingPackage != nil,
appIdentifier: item.isApplication ? item.apps.first : nil,
isFirst: isFirst,
@@ -218,7 +232,8 @@ struct MultipleAppsView: View {
if !item.isApplication, !keptBy.isEmpty, !item.isKeptByMacOS, !item.isPeels, !item.isExcluded {
lines.append(String(localized: "Not selected: it stays with \(names(of: keptBy))."))
}
- let users = item.sharedWithOthers.map(library.name(forBundleIdentifier:)) + item.otherCopies.map(\.abbreviatedPath)
+ let users =
+ item.sharedWithOthers.map(library.name(forBundleIdentifier:)) + item.otherCopies.map(\.abbreviatedPath)
if !users.isEmpty {
lines.append(String(localized: "Also used by \(users.formatted(.list(type: .and)))"))
}
@@ -307,10 +322,20 @@ struct MultipleAppsView: View {
let moved = Set(result.trashed.map(\.originalURL))
_ = await DockTiles().takeOut(appsInTheDock.filter(moved.contains).sorted { $0.path < $1.path })
}
- if let state = AppManagement.state(after: result, appBundles: Set(plan.apps.map(\.url)), movedByTheHelper: plan.privilegedURLs) {
+ if let state = AppManagement.state(
+ after: result,
+ appBundles: Set(plan.apps.map(\.url)),
+ movedByTheHelper: plan.privilegedURLs
+ ) {
home.record(appManagement: state)
}
- await history.record(result, tool: .applications, source: plan.historySource, sourceKey: plan.historySourceKey, sizes: request.sizes)
+ await history.record(
+ result,
+ tool: .applications,
+ source: plan.historySource,
+ sourceKey: plan.historySourceKey,
+ sizes: request.sizes
+ )
return result
}
// When an app bundle moved, reloading the library changes the selection, which rebuilds this page. When
@@ -320,7 +345,12 @@ struct MultipleAppsView: View {
if result.trashed.contains(where: { bundles.contains($0.originalURL) }) {
await library.checkAgain(await library.refresh())
} else {
- await plan.refresh(installedApps: library.apps, canUseHelper: helper.canAct, casks: homebrew.caskEvidence, receipts: homebrew.receipts)
+ await plan.refresh(
+ installedApps: library.apps,
+ canUseHelper: helper.canAct,
+ casks: homebrew.caskEvidence,
+ receipts: homebrew.receipts
+ )
}
}
}
diff --git a/Peel/Views/Notice.swift b/Peel/Views/Notice.swift
index 6783db54..47e718a6 100644
--- a/Peel/Views/Notice.swift
+++ b/Peel/Views/Notice.swift
@@ -33,7 +33,12 @@ struct Notice<Actions: View>: View {
HStack(spacing: 10) {
mark
words
- .frame(minWidth: Self.wordsFloor, idealWidth: Self.wordsFloor, maxWidth: .infinity, alignment: .leading)
+ .frame(
+ minWidth: Self.wordsFloor,
+ idealWidth: Self.wordsFloor,
+ maxWidth: .infinity,
+ alignment: .leading
+ )
buttons
}
VStack(alignment: .leading, spacing: 8) {
diff --git a/Peel/Views/Orphans/OrphanList.swift b/Peel/Views/Orphans/OrphanList.swift
index efbf807f..e1e49df5 100644
--- a/Peel/Views/Orphans/OrphanList.swift
+++ b/Peel/Views/Orphans/OrphanList.swift
@@ -26,7 +26,8 @@ struct OrphanList: View {
}
}
.scanState(phase(filtered), isRescanning: isRescanning, scan: orphans.scanRun) {
- if orphans.scan?.groups.isEmpty == true, let unreadable = orphans.scan?.unreadableLocations, !unreadable.isEmpty {
+ if orphans.scan?.groups.isEmpty == true, let unreadable = orphans.scan?.unreadableLocations,
+ !unreadable.isEmpty {
ContentUnavailableView {
Label("Not Everything Could Be Read", systemImage: "exclamationmark.triangle")
} description: {
@@ -61,7 +62,11 @@ struct OrphanList: View {
)
.toolbar {
ToolbarItem {
- RescanButton(isRunning: $isRescanning, isDisabled: !library.hasLoaded || orphans.isRemoving, scan: orphans.scanRun) {
+ RescanButton(
+ isRunning: $isRescanning,
+ isDisabled: !library.hasLoaded || orphans.isRemoving,
+ scan: orphans.scanRun
+ ) {
await orphans.refresh(from: library)
}
}
@@ -69,7 +74,9 @@ struct OrphanList: View {
// Scans again whenever the installed apps change, since a list made before an app was installed would
// call that app's files orphaned. It never restarts a first scan the user stopped.
.task(id: library.revision) {
- guard library.hasLoaded, orphans.scannedRevision != library.revision, !(orphans.scan == nil && orphans.scanRun.wasStopped) else { return }
+ guard library.hasLoaded, orphans.scannedRevision != library.revision,
+ !(orphans.scan == nil && orphans.scanRun.wasStopped)
+ else { return }
await orphans.refresh(from: library)
}
.rescanOnExclusionChange("OrphanList") { await orphans.refresh(from: library) }
@@ -85,7 +92,9 @@ struct OrphanList: View {
private var filteredGroups: [OrphanGroup] {
let groups = orphans.scan?.groups ?? []
guard !searchText.isEmpty else { return groups }
- return groups.filter { SearchText.matches($0.identifier, searchText) || SearchText.matches($0.title, searchText) }
+ return groups.filter {
+ SearchText.matches($0.identifier, searchText) || SearchText.matches($0.title, searchText)
+ }
}
}
diff --git a/Peel/Views/Packages/PackageDetailView.swift b/Peel/Views/Packages/PackageDetailView.swift
index b7afe412..9bcac980 100644
--- a/Peel/Views/Packages/PackageDetailView.swift
+++ b/Peel/Views/Packages/PackageDetailView.swift
@@ -91,7 +91,10 @@ struct PackageDetailView: View {
.fadesInColumn(whenRowsChange: receipt.items.map(\.id))
.navigationTitle(receipt.identifier)
.toolbar(removing: .title)
- .confirmationDialog(Text.movingToTrash(selectedItems.count, SizeTotal(selectedItems.map(\.size))), isPresented: $isConfirmingRemoval) {
+ .confirmationDialog(
+ Text.movingToTrash(selectedItems.count, SizeTotal(selectedItems.map(\.size))),
+ isPresented: $isConfirmingRemoval
+ ) {
Button("Move to Trash") {
Task {
let result = await packages.removeSelectedItems { result in
@@ -159,7 +162,8 @@ struct PackageDetailView: View {
}
private var selectableURLs: [URL] {
- receipt.items.filter { !$0.isLeftAlone && $0.heldBack == nil && (helper.canAct || !$0.requiresPrivileges) }.map(\.url)
+ receipt.items.filter { !$0.isLeftAlone && $0.heldBack == nil && (helper.canAct || !$0.requiresPrivileges) }
+ .map(\.url)
}
}
diff --git a/Peel/Views/Plugins/PluginDetailView.swift b/Peel/Views/Plugins/PluginDetailView.swift
index 68e83eb1..85e425cc 100644
--- a/Peel/Views/Plugins/PluginDetailView.swift
+++ b/Peel/Views/Plugins/PluginDetailView.swift
@@ -96,11 +96,19 @@ struct PluginDetailView: View {
.dimmedWhileBusy(plugins.isScanning)
.navigationTitle(plugin.name)
.toolbar(removing: .title)
- .confirmationDialog(Text.movingToTrash(plugin.name, SizeTotal([plugin.size])), isPresented: $isConfirmingRemoval) {
+ .confirmationDialog(
+ Text.movingToTrash(plugin.name, SizeTotal([plugin.size])),
+ isPresented: $isConfirmingRemoval
+ ) {
Button("Move to Trash") {
Task {
let result = await plugins.moveToTrash(plugin) { result in
- await history.record(result, tool: .plugins, source: plugin.name, sizes: [URL: Int64](measured: [(plugin.url, plugin.size)]))
+ await history.record(
+ result,
+ tool: .plugins,
+ source: plugin.name,
+ sizes: [URL: Int64](measured: [(plugin.url, plugin.size)])
+ )
}
outcome.report(result)
}
diff --git a/Peel/Views/Plugins/PluginList.swift b/Peel/Views/Plugins/PluginList.swift
index 69357d19..16a8c574 100644
--- a/Peel/Views/Plugins/PluginList.swift
+++ b/Peel/Views/Plugins/PluginList.swift
@@ -84,7 +84,8 @@ struct PluginList: View {
let all = plugins.plugins ?? []
guard !searchText.isEmpty else { return all }
return all.filter {
- SearchText.matches($0.name, searchText) || $0.bundleIdentifier.map { identifier in SearchText.matches(identifier, searchText) } == true
+ SearchText.matches($0.name, searchText)
+ || $0.bundleIdentifier.map { identifier in SearchText.matches(identifier, searchText) } == true
}
}
}
diff --git a/Peel/Views/Projects/ProjectList.swift b/Peel/Views/Projects/ProjectList.swift
index 60483860..58a0d455 100644
--- a/Peel/Views/Projects/ProjectList.swift
+++ b/Peel/Views/Projects/ProjectList.swift
@@ -120,7 +120,11 @@ struct ProjectList: View {
.help(Text("The folders Peel looks through"))
}
ToolbarItem {
- RescanButton(isRunning: $isRescanning, isDisabled: projects.folders.isEmpty || projects.isRemoving, scan: projects.scanRun) {
+ RescanButton(
+ isRunning: $isRescanning,
+ isDisabled: projects.folders.isEmpty || projects.isRemoving,
+ scan: projects.scanRun
+ ) {
await projects.refresh()
}
}
diff --git a/Peel/Views/RemovalBar.swift b/Peel/Views/RemovalBar.swift
index c3c50f47..1bb7765f 100644
--- a/Peel/Views/RemovalBar.swift
+++ b/Peel/Views/RemovalBar.swift
@@ -61,7 +61,11 @@ struct RemovalBar: View {
systemImage: String = "trash",
notice: BarNotice? = nil
) {
- purpose = .own(SizeTotal(known: selectedSize, isComplete: isSelectionMeasured), isEnabled: isEnabled, onRemove: onRemove)
+ purpose = .own(
+ SizeTotal(known: selectedSize, isComplete: isSelectionMeasured),
+ isEnabled: isEnabled,
+ onRemove: onRemove
+ )
self.isScanning = isScanning
self.isWorking = isWorking
self.scan = scan
@@ -91,7 +95,12 @@ struct RemovalBar: View {
private var reading: Reading {
switch purpose {
case .own(let total, let isEnabled, let onRemove):
- return Reading(total: total, pages: nil, isEnabled: isEnabled && !isScanning && !isWorking, remove: onRemove)
+ return Reading(
+ total: total,
+ pages: nil,
+ isEnabled: isEnabled && !isScanning && !isWorking,
+ remove: onRemove
+ )
case .carried(let page, _):
let parts = carrier.parts(from: page)
return Reading(
diff --git a/Peel/Views/RemovalFailureAlert.swift b/Peel/Views/RemovalFailureAlert.swift
index 7fbb35d3..46ec7fd7 100644
--- a/Peel/Views/RemovalFailureAlert.swift
+++ b/Peel/Views/RemovalFailureAlert.swift
@@ -95,7 +95,8 @@ struct RemovalFailureAlert: ViewModifier {
/// That refusal comes from App Management, which the user can allow in System Settings.
private var needsAppManagement: Bool {
outcome.failures.contains { failure in
- failure.reason == .notPermitted && failure.url.pathExtension.lowercased() == "app" && AppManagement.isRefusedForWantOfPermission(failure.url)
+ failure.reason == .notPermitted && failure.url.pathExtension.lowercased() == "app"
+ && AppManagement.isRefusedForWantOfPermission(failure.url)
}
}
diff --git a/Peel/Views/RemovalRow.swift b/Peel/Views/RemovalRow.swift
index eba8351b..6a303cca 100644
--- a/Peel/Views/RemovalRow.swift
+++ b/Peel/Views/RemovalRow.swift
@@ -73,7 +73,12 @@ struct RemovalRow: View {
proxy.size.width < limit
} action: { isCompact = $0 }
.contextMenu {
- ItemMenu(url: url, appIdentifier: appIdentifier, isExcluded: isExcluded, showNote: hasNote ? { isNoteOpen = true } : nil)
+ ItemMenu(
+ url: url,
+ appIdentifier: appIdentifier,
+ isExcluded: isExcluded,
+ showNote: hasNote ? { isNoteOpen = true } : nil
+ )
}
}
diff --git a/Peel/Views/ScanState.swift b/Peel/Views/ScanState.swift
index c15d82a9..ed150db1 100644
--- a/Peel/Views/ScanState.swift
+++ b/Peel/Views/ScanState.swift
@@ -31,11 +31,24 @@ extension View {
scan: ScanRun? = nil,
@ViewBuilder message: () -> some View
) -> some View {
- modifier(ScanStateModifier(phase: phase, isRescanning: isRescanning, fadesInResults: fadesInResults, scan: scan, message: message()))
+ modifier(
+ ScanStateModifier(
+ phase: phase,
+ isRescanning: isRescanning,
+ fadesInResults: fadesInResults,
+ scan: scan,
+ message: message()
+ )
+ )
}
/// The same, for a page with no message of its own.
- func scanState(_ phase: ScanPhase, isRescanning: Bool = false, fadesInResults: Bool = true, scan: ScanRun? = nil) -> some View {
+ func scanState(
+ _ phase: ScanPhase,
+ isRescanning: Bool = false,
+ fadesInResults: Bool = true,
+ scan: ScanRun? = nil
+ ) -> some View {
scanState(phase, isRescanning: isRescanning, fadesInResults: fadesInResults, scan: scan) { EmptyView() }
}
}
@@ -92,7 +105,10 @@ private struct WalkLabel: View {
let scan: ScanRun?
var body: some View {
- if AppDataQuestion.isAsked(frontmost: FrontmostApp.shared.bundleIdentifier, hasFullDiskAccess: home.states[.fullDiskAccess] == .on) {
+ if AppDataQuestion.isAsked(
+ frontmost: FrontmostApp.shared.bundleIdentifier,
+ hasFullDiskAccess: home.states[.fullDiskAccess] == .on
+ ) {
Text("macOS is asking whether Peel may access data from other apps. The scan continues once you answer.")
} else {
ReadSoFar(scan: scan)
diff --git a/Peel/Views/Settings/ExclusionsSettingsView.swift b/Peel/Views/Settings/ExclusionsSettingsView.swift
index 7d7a8542..99ed4180 100644
--- a/Peel/Views/Settings/ExclusionsSettingsView.swift
+++ b/Peel/Views/Settings/ExclusionsSettingsView.swift
@@ -120,7 +120,11 @@ struct ExclusionsSettingsView: View {
}
HStack {
Menu {
- ForEach(library.apps.filter { !exclusions.exclusions.excludes(bundleIdentifier: $0.bundleIdentifier) }) { app in
+ ForEach(
+ library.apps.filter {
+ !exclusions.exclusions.excludes(bundleIdentifier: $0.bundleIdentifier)
+ }
+ ) { app in
Button(app.name) {
Task { await exclusions.add(bundleIdentifier: app.bundleIdentifier) }
}
@@ -182,7 +186,11 @@ struct ExclusionsSettingsView: View {
.formStyle(.grouped)
// `.folder` is listed as well as `.item`: with `.item` alone, the panel doesn't let the user choose a
// folder, even though a folder conforms to `.item`.
- .fileImporter(isPresented: $isChoosingPaths, allowedContentTypes: [.item, .folder], allowsMultipleSelection: true) { result in
+ .fileImporter(
+ isPresented: $isChoosingPaths,
+ allowedContentTypes: [.item, .folder],
+ allowsMultipleSelection: true
+ ) { result in
guard let urls = try? result.get() else { return }
// Excluding a folder as broad as the home folder or `/Applications` would leave the tools with little
// or nothing to show, without saying why. A bare `/` would protect nothing: `Exclusions` ignores it.
diff --git a/Peel/Views/Settings/SavedSettingsSection.swift b/Peel/Views/Settings/SavedSettingsSection.swift
index 670260b0..2266ff26 100644
--- a/Peel/Views/Settings/SavedSettingsSection.swift
+++ b/Peel/Views/Settings/SavedSettingsSection.swift
@@ -98,7 +98,12 @@ struct SavedSettingsSection: View {
guard let app = library.apps.first(where: { $0.bundleIdentifier == bundleIdentifier }) else {
return !NSRunningApplication.runningApplications(withBundleIdentifier: bundleIdentifier).isEmpty
}
- return !RunningCopies.belonging(to: app, among: RunningCopies.current, installedApps: library.apps, sharingItsSettings: true).isEmpty
+ return !RunningCopies.belonging(
+ to: app,
+ among: RunningCopies.current,
+ installedApps: library.apps,
+ sharingItsSettings: true
+ ).isEmpty
}
private func refreshOpenApps() {
@@ -111,7 +116,11 @@ struct SavedSettingsSection: View {
// Asked again at the moment of Put Back and before the settings in use are cleared: an app opened since the
// row was drawn would write its own settings over these when it quits.
let restored = await QuitGuard.shared.run {
- await PreferenceBackup.restore(from: copy.folder, of: copy.bundleIdentifier, exclusions: ExclusionsStore.shared.exclusions) { @MainActor in
+ await PreferenceBackup.restore(
+ from: copy.folder,
+ of: copy.bundleIdentifier,
+ exclusions: ExclusionsStore.shared.exclusions
+ ) { @MainActor in
isRunning(copy.bundleIdentifier)
}
}
@@ -144,7 +153,12 @@ struct SavedSettingsSection: View {
if let reason = result.failures.first?.reason {
failure = Failure(title: String(localized: "The copy couldn’t be moved to the Trash."), message: reason.explanation)
}
- await history.record(result, tool: .applications, source: name, sizes: [URL: Int64](measured: [(copy.folder, size)]))
+ await history.record(
+ result,
+ tool: .applications,
+ source: name,
+ sizes: [URL: Int64](measured: [(copy.folder, size)])
+ )
}
reload()
}
diff --git a/Peel/Views/Settings/SettingsView.swift b/Peel/Views/Settings/SettingsView.swift
index bfce4048..533c420e 100644
--- a/Peel/Views/Settings/SettingsView.swift
+++ b/Peel/Views/Settings/SettingsView.swift
@@ -84,7 +84,10 @@ enum SettingsKey {
/// Nil while something that may not be Peel's is where the link goes.
static var commandLineInstallCommand: String? {
- CommandLineTool.installCommand(embedded: Bundle.main.bundleURL.appending(path: "Contents/Helpers/peel"), standing: HomeModel.commandLineStanding)
+ CommandLineTool.installCommand(
+ embedded: Bundle.main.bundleURL.appending(path: "Contents/Helpers/peel"),
+ standing: HomeModel.commandLineStanding
+ )
}
}
@@ -368,7 +371,11 @@ private struct GeneralSettingsView: View {
.confirmationDialog("Remove Peel from this Mac?", isPresented: $isConfirmingSelfRemoval) {
Button("Remove Peel", role: .destructive) {
Task {
- await selfUninstall.run(installedApps: library.apps, helper: helper, pausing: background) { result in
+ await selfUninstall.run(
+ installedApps: library.apps,
+ helper: helper,
+ pausing: background
+ ) { result in
await history.record(result, tool: .applications, source: "Peel", sizes: [:])
}
}
@@ -456,7 +463,11 @@ extension GeneralSettingsView {
}
extension GeneralSettingsView {
- fileprivate func toggle(_ title: LocalizedStringResource, isOn: Binding<Bool>, _ detail: LocalizedStringResource) -> some View {
+ fileprivate func toggle(
+ _ title: LocalizedStringResource,
+ isOn: Binding<Bool>,
+ _ detail: LocalizedStringResource
+ ) -> some View {
LabeledContent {
Toggle(isOn: isOn) { EmptyView() }
.labelsHidden()
diff --git a/Peel/Views/Space/SpaceList.swift b/Peel/Views/Space/SpaceList.swift
index 63fc79a3..363ab68b 100644
--- a/Peel/Views/Space/SpaceList.swift
+++ b/Peel/Views/Space/SpaceList.swift
@@ -56,7 +56,11 @@ struct SpaceList: View {
}
}
.columnSearch(text: $searchText, prompt: "Search Space", when: space.report?.items.isEmpty == false)
- .scanState(space.report != nil ? .content : space.scanRun.wasStopped ? .stopped : .scanning(.walk), isRescanning: isRescanning, scan: space.scanRun)
+ .scanState(
+ space.report != nil ? .content : space.scanRun.wasStopped ? .stopped : .scanning(.walk),
+ isRescanning: isRescanning,
+ scan: space.scanRun
+ )
.fadesInColumn(whenRowsChange: space.report?.items.map(\.id))
.navigationTitle(Text(Tool.space.title))
.announcesScan(space.isScanning, found: space.summary, wasStopped: space.scanRun.wasStopped)
diff --git a/Peel/Views/Stickers/PeelFace.swift b/Peel/Views/Stickers/PeelFace.swift
index 38a3717f..6f6b3ff4 100644
--- a/Peel/Views/Stickers/PeelFace.swift
+++ b/Peel/Views/Stickers/PeelFace.swift
@@ -140,7 +140,11 @@ private final class FaceLayerView: NSView {
MainActor.assumeIsolated { self?.refresh() }
})
}
- observers.append(center.addObserver(forName: NSWindow.didChangeOcclusionStateNotification, object: window, queue: .main) { [weak self] _ in
+ observers.append(center.addObserver(
+ forName: NSWindow.didChangeOcclusionStateNotification,
+ object: window,
+ queue: .main
+ ) { [weak self] _ in
MainActor.assumeIsolated { self?.refresh() }
})
refresh()
@@ -205,7 +209,9 @@ private final class FaceLayerView: NSView {
link?.preferredFrameRateRange = quick ? .default : Self.calm
}
let pose = Pose(Idle(at: time * 1000, amplitude: isStill ? 0 : 1), look, size: size)
- guard motion.isWorthAFrame(pose.corners, pixelsPerPoint: Double(window?.backingScaleFactor ?? 2)) else { return }
+ guard motion.isWorthAFrame(pose.corners, pixelsPerPoint: Double(window?.backingScaleFactor ?? 2)) else {
+ return
+ }
CATransaction.begin()
CATransaction.setDisableActions(true)
head.transform = pose.head.transform
@@ -287,8 +293,10 @@ private struct Pose {
.then(CATransform3DMakeRotation(tilt * side * .pi / 180, 0, 0, 1))
.then(CATransform3DMakeScale(scale.width, scale.height, 1))
.then(CATransform3DMakeRotation(smile.tilt(side) * .pi / 180, 0, 0, 1)),
- position: CGPoint(x: (Face.center.x + side * Face.gap + glance.width + smile.offset(side).width) * unit,
- y: (Face.center.y + glance.height + smile.offset(side).height) * unit)))
+ position: CGPoint(x: (Face.center.x + side * Face.gap + glance.width
+ + smile.offset(side).width) * unit,
+ y: (Face.center.y + glance.height
+ + smile.offset(side).height) * unit)))
}
}
@@ -300,7 +308,8 @@ private struct Pose {
let offset = CGPoint(x: point.x - size / 2, y: point.y - size / 2).applying(turned)
return [head.position.x + offset.x, head.position.y + offset.y]
}
- var points = [CGPoint(x: 0, y: 0), CGPoint(x: size, y: 0), CGPoint(x: size, y: size), CGPoint(x: 0, y: size)].map(onCanvas)
+ var points = [CGPoint(x: 0, y: 0), CGPoint(x: size, y: 0), CGPoint(x: size, y: size), CGPoint(x: 0, y: size)]
+ .map(onCanvas)
let half = CGSize(width: Face.eye.width * size / 200, height: Face.eye.height * size / 200)
for eye in eyes {
let shaped = CATransform3DGetAffineTransform(eye.transform)
@@ -312,7 +321,9 @@ private struct Pose {
}
let reach = Face.dot.radius * dot * size / 100
let middle = SIMD2(Face.dot.x * size / 100, Face.dot.y * size / 100)
- points += [middle + [-reach, -reach], middle + [reach, -reach], middle + [reach, reach], middle + [-reach, reach]]
+ points += [
+ middle + [-reach, -reach], middle + [reach, -reach], middle + [reach, reach], middle + [-reach, reach],
+ ]
return points
}
}
@@ -406,10 +417,12 @@ private final class Follow {
let toward = CGSize(width: pointer.x - Face.center.x, height: pointer.y - Face.center.y)
let reach = hypot(toward.width, toward.height)
let near = Self.smoothstep(min(1, reach / (Face.radius * 100 * 0.55)))
- target = reach > 0 ? CGSize(width: toward.width / reach * near, height: toward.height / reach * near) : .zero
+ target =
+ reach > 0 ? CGSize(width: toward.width / reach * near, height: toward.height / reach * near) : .zero
held = 1
} else {
- let plan = lookingAround?.plan ?? LookAround(from: .init(aim: [look.aim.width, look.aim.height], hold: holding))
+ let plan =
+ lookingAround?.plan ?? LookAround(from: .init(aim: [look.aim.width, look.aim.height], hold: holding))
let elapsed = (lookingAround?.elapsed ?? 0) + step
lookingAround = (plan, elapsed)
let moment = plan.moment(after: elapsed)
@@ -557,7 +570,8 @@ private struct Idle {
guard index + 1 < table.count else { return table[index][column] }
let span = table[index + 1][0] - table[index][0]
guard span > 0 else { return table[index][column] }
- return table[index][column] + (table[index + 1][column] - table[index][column]) * ((position - table[index][0]) / span)
+ return table[index][column]
+ + (table[index + 1][column] - table[index][column]) * ((position - table[index][0]) / span)
}
return table[0][column]
}
diff --git a/Peel/Views/Terminal/TerminalPage.swift b/Peel/Views/Terminal/TerminalPage.swift
index 7ae7d5bd..97ba7534 100644
--- a/Peel/Views/Terminal/TerminalPage.swift
+++ b/Peel/Views/Terminal/TerminalPage.swift
@@ -65,10 +65,14 @@ struct TerminalPage: View {
.onChange(of: history.revision) {
terminal.refresh()
}
- .onReceive(NSWorkspace.shared.notificationCenter.publisher(for: NSWorkspace.didLaunchApplicationNotification)) { _ in
+ .onReceive(
+ NSWorkspace.shared.notificationCenter.publisher(for: NSWorkspace.didLaunchApplicationNotification)
+ ) { _ in
terminal.refresh()
}
- .onReceive(NSWorkspace.shared.notificationCenter.publisher(for: NSWorkspace.didTerminateApplicationNotification)) { _ in
+ .onReceive(
+ NSWorkspace.shared.notificationCenter.publisher(for: NSWorkspace.didTerminateApplicationNotification)
+ ) { _ in
terminal.refresh()
}
.alert("Quit Terminal first?", isPresented: isWaitingForTerminal, presenting: terminal.waitingForTerminal) { action in
diff --git a/Peel/Views/Terminal/TerminalPreview.swift b/Peel/Views/Terminal/TerminalPreview.swift
index debb4476..62604771 100644
--- a/Peel/Views/Terminal/TerminalPreview.swift
+++ b/Peel/Views/Terminal/TerminalPreview.swift
@@ -3,7 +3,12 @@ import SwiftUI
extension Color {
init(terminal color: UInt32) {
- self.init(.sRGB, red: Double(color >> 16 & 0xFF) / 255, green: Double(color >> 8 & 0xFF) / 255, blue: Double(color & 0xFF) / 255)
+ self.init(
+ .sRGB,
+ red: Double(color >> 16 & 0xFF) / 255,
+ green: Double(color >> 8 & 0xFF) / 255,
+ blue: Double(color & 0xFF) / 255
+ )
}
}
diff --git a/Peel/Views/Terminal/TerminalRows.swift b/Peel/Views/Terminal/TerminalRows.swift
index 4332201f..bcdeb43d 100644
--- a/Peel/Views/Terminal/TerminalRows.swift
+++ b/Peel/Views/Terminal/TerminalRows.swift
@@ -52,7 +52,11 @@ struct PromptSample: View {
style.sample(user: user, host: host, path: "~/Projects/peel", branch: "main", failed: false)
}
- static func width(of styles: [PromptStyle], user: String = NSUserName(), host: String = PromptStyle.hostName()) -> CGFloat {
+ static func width(
+ of styles: [PromptStyle],
+ user: String = NSUserName(),
+ host: String = PromptStyle.hostName()
+ ) -> CGFloat {
let lines = styles.flatMap { segments(of: $0, user: user, host: host).map(\.text).joined().split(separator: "\n") }
return ceil(lines.map { (String($0) as NSString).size(withAttributes: [.font: font]).width }.max() ?? 0) + 16
}
@@ -68,7 +72,10 @@ struct PromptSample: View {
.padding(.horizontal, 8)
.padding(.vertical, 5)
.frame(width: width, alignment: .leading)
- .background(theme.map { Color(terminal: $0.background) } ?? Color(nsColor: .textBackgroundColor), in: .rect(cornerRadius: 6))
+ .background(
+ theme.map { Color(terminal: $0.background) } ?? Color(nsColor: .textBackgroundColor),
+ in: .rect(cornerRadius: 6)
+ )
.overlay { RoundedRectangle(cornerRadius: 6).strokeBorder(.separator) }
.accessibilityHidden(true)
}
diff --git a/Peel/Views/ToolSummaries.swift b/Peel/Views/ToolSummaries.swift
index 14b6084a..d7bee42d 100644
--- a/Peel/Views/ToolSummaries.swift
+++ b/Peel/Views/ToolSummaries.swift
@@ -69,7 +69,9 @@ extension AppLibrary {
let known = sizes.values.cappedSum
let total = SizeTotal(known: known, isComplete: sizes.count >= count)
let size = known > 0 ? AttributedString(localized: "\(total.text) in ^[\(count) app](inflect: true).") : AttributedString(localized: "^[\(count) app](inflect: true).")
- guard let updates = Tool.applications.summary(of: Looked(count: appsWithUpdates.count, size: nil)) else { return size }
+ guard let updates = Tool.applications.summary(of: Looked(count: appsWithUpdates.count, size: nil)) else {
+ return size
+ }
return size + AttributedString("\n") + updates
}
}
@@ -106,7 +108,12 @@ extension HomebrewLibrary {
extension FileSearchLibrary {
var summary: AttributedString? {
results.flatMap { results in
- Tool.fileSearch.summary(of: Looked(count: results.files.count, size: SizeTotal(known: results.files.map(\.size).cappedSum, isComplete: true)))
+ Tool.fileSearch.summary(
+ of: Looked(
+ count: results.files.count,
+ size: SizeTotal(known: results.files.map(\.size).cappedSum, isComplete: true)
+ )
+ )
}
}
}
diff --git a/Peel/Views/VendorNotes.swift b/Peel/Views/VendorNotes.swift
index e04b03e5..845ea9e9 100644
--- a/Peel/Views/VendorNotes.swift
+++ b/Peel/Views/VendorNotes.swift
@@ -75,9 +75,14 @@ struct PackageReceiptSection: View {
}
@concurrent
- private nonisolated static func receipts(of app: InstalledApp, exclusions: Exclusions) async -> ([PackageReceipt], [PackageReceipt.ID: [PackageReceipt.Item]]) {
+ private nonisolated static func receipts(
+ of app: InstalledApp,
+ exclusions: Exclusions
+ ) async -> ([PackageReceipt], [PackageReceipt.ID: [PackageReceipt.Item]]) {
let receipts = await PackageReceipts.receipts(installing: app.url, exclusions: exclusions)
- let files = receipts.map { ($0.id, VendorRemoval.filesOutsideBundle(of: $0, app: app, otherReceipts: receipts)) }
+ let files = receipts.map {
+ ($0.id, VendorRemoval.filesOutsideBundle(of: $0, app: app, otherReceipts: receipts))
+ }
return (receipts, Dictionary(files, uniquingKeysWith: { first, _ in first }))
}
diff --git a/Peel/Views/WholeWords.swift b/Peel/Views/WholeWords.swift
index 3147dd0d..03a442dd 100644
--- a/Peel/Views/WholeWords.swift
+++ b/Peel/Views/WholeWords.swift
@@ -23,7 +23,9 @@ struct LongestWord: View {
var words: [String] = []
text.enumerateSubstrings(in: text.startIndex..., options: [.byWords, .substringNotRequired]) { _, range, _, _ in
var start = range.lowerBound, end = range.upperBound
- while start > text.startIndex, isAttached(text[text.index(before: start)]) { start = text.index(before: start) }
+ while start > text.startIndex, isAttached(text[text.index(before: start)]) {
+ start = text.index(before: start)
+ }
while end < text.endIndex, isAttached(text[end]) { end = text.index(after: end) }
words.append(String(text[start..<end]))
}