From 5456d60876be4516125f4b98728a645a6e9aed61 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Fri, 12 Dec 2025 06:12:13 +0000 Subject: [PATCH] chore: auto format code --- cmd/analyze/scanner.go | 2 +- cmd/status/metrics.go | 26 +++++++++++++------------- lib/clean/apps.sh | 5 ++--- lib/clean/brew.sh | 5 ++--- lib/clean/system.sh | 2 -- lib/core/app_protection.sh | 26 +++++++++++++------------- lib/core/log.sh | 2 +- lib/manage/update.sh | 12 ++++++------ lib/optimize/tasks.sh | 4 ---- 9 files changed, 38 insertions(+), 46 deletions(-) diff --git a/cmd/analyze/scanner.go b/cmd/analyze/scanner.go index ad2064d..8bab00c 100644 --- a/cmd/analyze/scanner.go +++ b/cmd/analyze/scanner.go @@ -306,7 +306,7 @@ func calculateDirSizeFast(root string, filesScanned, dirsScanned, bytesScanned * subDir := filepath.Join(dirPath, entry.Name()) go func(p string) { defer wg.Done() - sem <- struct{}{} // Acquire token + sem <- struct{}{} // Acquire token defer func() { <-sem }() // Release token walk(p) }(subDir) diff --git a/cmd/status/metrics.go b/cmd/status/metrics.go index 9029a88..c61ed0b 100644 --- a/cmd/status/metrics.go +++ b/cmd/status/metrics.go @@ -163,22 +163,22 @@ func (c *Collector) Collect() (MetricsSnapshot, error) { hostInfo, _ := host.Info() var ( - wg sync.WaitGroup - errMu sync.Mutex - mergeErr error + wg sync.WaitGroup + errMu sync.Mutex + mergeErr error - cpuStats CPUStatus - memStats MemoryStatus - diskStats []DiskStatus - diskIO DiskIOStatus - netStats []NetworkStatus - proxyStats ProxyStatus + cpuStats CPUStatus + memStats MemoryStatus + diskStats []DiskStatus + diskIO DiskIOStatus + netStats []NetworkStatus + proxyStats ProxyStatus batteryStats []BatteryStatus thermalStats ThermalStatus - sensorStats []SensorReading - gpuStats []GPUStatus - btStats []BluetoothDevice - topProcs []ProcessInfo + sensorStats []SensorReading + gpuStats []GPUStatus + btStats []BluetoothDevice + topProcs []ProcessInfo ) // Helper to launch concurrent collection diff --git a/lib/clean/apps.sh b/lib/clean/apps.sh index fd61134..52b1755 100644 --- a/lib/clean/apps.sh +++ b/lib/clean/apps.sh @@ -164,8 +164,8 @@ scan_installed_apps() { ( run_with_timeout 5 find ~/Library/LaunchAgents /Library/LaunchAgents \ - -name "*.plist" -type f 2> /dev/null | - xargs -I {} basename {} .plist > "$scan_tmp_dir/agents.txt" 2> /dev/null || true + -name "*.plist" -type f 2> /dev/null | + xargs -I {} basename {} .plist > "$scan_tmp_dir/agents.txt" 2> /dev/null || true ) & pids+=($!) @@ -212,7 +212,6 @@ is_bundle_orphaned() { return 1 fi - # Extra check for specific system bundles not covered by patterns case "$bundle_id" in loginwindow | dock | systempreferences | finder | safari) diff --git a/lib/clean/brew.sh b/lib/clean/brew.sh index 64e53a2..631f102 100644 --- a/lib/clean/brew.sh +++ b/lib/clean/brew.sh @@ -38,7 +38,7 @@ clean_orphaned_casks() { rm -f "$cask_cache" 2> /dev/null || true true > "$cask_cache" - while IFS= read -r cask; do + while IFS= read -r cask; do # Get app path from cask info with timeout protection (expensive call, hence caching) local cask_info cask_info=$(run_with_timeout 10 brew info --cask "$cask" 2> /dev/null || true) @@ -62,12 +62,11 @@ clean_orphaned_casks() { # Check if app exists into common locations # We must check both /Applications and ~/Applications if [[ ! -e "/Applications/$app_name" ]] && [[ ! -e "$HOME/Applications/$app_name" ]]; then - orphaned_casks+=("$cask") + orphaned_casks+=("$cask") fi done < <(brew list --cask 2> /dev/null || true) fi - # Remove orphaned casks if found and sudo session is still valid if [[ ${#orphaned_casks[@]} -gt 0 ]]; then # Check if sudo session is still valid (without prompting) diff --git a/lib/clean/system.sh b/lib/clean/system.sh index 924eaf3..97f131a 100644 --- a/lib/clean/system.sh +++ b/lib/clean/system.sh @@ -52,8 +52,6 @@ clean_deep_system() { fi fi - - # Clean macOS Install Data (system upgrade leftovers) # Only remove if older than 30 days to ensure system stability if [[ -d "/macOS Install Data" ]]; then diff --git a/lib/core/app_protection.sh b/lib/core/app_protection.sh index 8f23dd4..f20d759 100755 --- a/lib/core/app_protection.sh +++ b/lib/core/app_protection.sh @@ -734,23 +734,23 @@ find_app_receipt_files() { # Whitelisted prefixes case "$clean_path" in /Applications/*) is_safe=true ;; - /Users/*) is_safe=true ;; - /usr/local/*) is_safe=true ;; - /opt/*) is_safe=true ;; + /Users/*) is_safe=true ;; + /usr/local/*) is_safe=true ;; + /opt/*) is_safe=true ;; /Library/*) # Filter sub-paths in /Library to avoid system damage # Allow safely: Application Support, Caches, Logs, Preferences case "$clean_path" in /Library/Application\ Support/*) is_safe=true ;; - /Library/Caches/*) is_safe=true ;; - /Library/Logs/*) is_safe=true ;; - /Library/Preferences/*) is_safe=true ;; + /Library/Caches/*) is_safe=true ;; + /Library/Logs/*) is_safe=true ;; + /Library/Preferences/*) is_safe=true ;; /Library/PrivilegedHelperTools/*) is_safe=true ;; - /Library/LaunchAgents/*) is_safe=true ;; - /Library/LaunchDaemons/*) is_safe=true ;; - /Library/Internet\ Plug-Ins/*) is_safe=true ;; - /Library/Audio/Plug-Ins/*) is_safe=true ;; - /Library/Extensions/*) is_safe=false ;; # Default unsafe + /Library/LaunchAgents/*) is_safe=true ;; + /Library/LaunchDaemons/*) is_safe=true ;; + /Library/Internet\ Plug-Ins/*) is_safe=true ;; + /Library/Audio/Plug-Ins/*) is_safe=true ;; + /Library/Extensions/*) is_safe=false ;; # Default unsafe *) is_safe=false ;; esac ;; @@ -758,7 +758,7 @@ find_app_receipt_files() { # Hard blocks case "$clean_path" in - /System/*|/usr/bin/*|/usr/lib/*|/bin/*|/sbin/*) is_safe=false ;; + /System/* | /usr/bin/* | /usr/lib/* | /bin/* | /sbin/*) is_safe=false ;; esac if [[ "$is_safe" == "true" && -e "$clean_path" ]]; then @@ -774,7 +774,7 @@ find_app_receipt_files() { # Extra check: path must be deep enough? # If path is just "/Applications", skip. if [[ "$clean_path" == "/Applications" || "$clean_path" == "/Library" || "$clean_path" == "/usr/local" ]]; then - continue + continue fi receipt_files+=("$clean_path") diff --git a/lib/core/log.sh b/lib/core/log.sh index 59ca598..6c08276 100644 --- a/lib/core/log.sh +++ b/lib/core/log.sh @@ -127,7 +127,7 @@ log_system_info() { echo "Shell: ${SHELL:-unknown} (${TERM:-unknown})" # Check sudo status non-interactively - if sudo -n true 2>/dev/null; then + if sudo -n true 2> /dev/null; then echo "Sudo Access: Active" else echo "Sudo Access: Required" diff --git a/lib/manage/update.sh b/lib/manage/update.sh index 0838bb6..de4787d 100644 --- a/lib/manage/update.sh +++ b/lib/manage/update.sh @@ -254,12 +254,12 @@ perform_updates() { if [[ -x "$mole_bin" ]]; then if "$mole_bin" update 2>&1 | grep -qE "(Updated|latest version)"; then - echo -e "${GREEN}✓${NC} Mole updated" - reset_mole_cache - ((updated_count++)) - else - echo -e "${RED}✗${NC} Mole update failed" - fi + echo -e "${GREEN}✓${NC} Mole updated" + reset_mole_cache + ((updated_count++)) + else + echo -e "${RED}✗${NC} Mole update failed" + fi else echo -e "${RED}✗${NC} Mole executable not found" fi diff --git a/lib/optimize/tasks.sh b/lib/optimize/tasks.sh index 920abe2..021d8cb 100644 --- a/lib/optimize/tasks.sh +++ b/lib/optimize/tasks.sh @@ -16,8 +16,6 @@ opt_system_maintenance() { echo -e "${RED}${ICON_ERROR}${NC} Failed to clear DNS cache" fi - - echo -e "${BLUE}${ICON_ARROW}${NC} Checking Spotlight index..." local md_status md_status=$(mdutil -s / 2> /dev/null || echo "") @@ -31,7 +29,6 @@ opt_system_maintenance() { sudo pkill -f blued 2> /dev/null || true echo -e "${GREEN}${ICON_SUCCESS}${NC} Bluetooth controller refreshed" - } # Cache refresh: update Finder/Safari caches @@ -112,7 +109,6 @@ opt_radio_refresh() { echo -e "${BLUE}${ICON_ARROW}${NC} Refreshing Wi-Fi service..." # Only restart Wi-Fi service, do NOT delete saved networks - # Safe alternative: just restart the Wi-Fi interface local wifi_interface wifi_interface=$(networksetup -listallhardwareports | awk '/Wi-Fi/{getline; print $2}' | head -1)