From 88c5f92ac48d13f14e5aa6a63f2c63b2ae246a08 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Mon, 8 Dec 2025 18:59:52 +0800 Subject: [PATCH] format --- bin/optimize.sh | 2 +- lib/check/all.sh | 22 +++++++++++----------- lib/core/app_protection.sh | 36 ++++++++++++++++++------------------ lib/core/base.sh | 2 +- lib/core/common.sh | 2 +- lib/core/file_ops.sh | 4 ++-- lib/manage/whitelist.sh | 6 +++--- lib/uninstall/batch.sh | 2 +- 8 files changed, 38 insertions(+), 38 deletions(-) diff --git a/bin/optimize.sh b/bin/optimize.sh index 583561c..afe5fb9 100755 --- a/bin/optimize.sh +++ b/bin/optimize.sh @@ -349,7 +349,7 @@ main() { clear fi print_header # Outputs "Optimize and Check" - + # Check dependencies if ! command -v jq > /dev/null 2>&1; then echo -e "${RED}${ICON_ERROR}${NC} Missing dependency: jq" diff --git a/lib/check/all.sh b/lib/check/all.sh index 9cd4cbd..10fe730 100644 --- a/lib/check/all.sh +++ b/lib/check/all.sh @@ -31,7 +31,7 @@ list_login_items() { check_touchid_sudo() { # Check whitelist - if command -v is_whitelisted >/dev/null && is_whitelisted "check_touchid"; then return; fi + if command -v is_whitelisted > /dev/null && is_whitelisted "check_touchid"; then return; fi # Check if Touch ID is configured for sudo local pam_file="/etc/pam.d/sudo" if [[ -f "$pam_file" ]] && grep -q "pam_tid.so" "$pam_file" 2> /dev/null; then @@ -56,7 +56,7 @@ check_touchid_sudo() { check_rosetta() { # Check whitelist - if command -v is_whitelisted >/dev/null && is_whitelisted "check_rosetta"; then return; fi + if command -v is_whitelisted > /dev/null && is_whitelisted "check_rosetta"; then return; fi # Check Rosetta 2 (for Apple Silicon Macs) if [[ "$(uname -m)" == "arm64" ]]; then if [[ -f "/Library/Apple/usr/share/rosetta/rosetta" ]]; then @@ -70,7 +70,7 @@ check_rosetta() { check_git_config() { # Check whitelist - if command -v is_whitelisted >/dev/null && is_whitelisted "check_git_config"; then return; fi + if command -v is_whitelisted > /dev/null && is_whitelisted "check_git_config"; then return; fi # Check basic Git configuration if command -v git > /dev/null 2>&1; then local git_name=$(git config --global user.name 2> /dev/null || echo "") @@ -96,7 +96,7 @@ check_all_config() { check_filevault() { # Check whitelist - if command -v is_whitelisted >/dev/null && is_whitelisted "check_filevault"; then return; fi + if command -v is_whitelisted > /dev/null && is_whitelisted "check_filevault"; then return; fi # Check FileVault encryption status if command -v fdesetup > /dev/null 2>&1; then local fv_status=$(fdesetup status 2> /dev/null || echo "") @@ -111,7 +111,7 @@ check_filevault() { check_firewall() { # Check whitelist - if command -v is_whitelisted >/dev/null && is_whitelisted "firewall"; then return; fi + if command -v is_whitelisted > /dev/null && is_whitelisted "firewall"; then return; fi # Check firewall status unset FIREWALL_DISABLED local firewall_status=$(defaults read /Library/Preferences/com.apple.alf globalstate 2> /dev/null || echo "0") @@ -127,7 +127,7 @@ check_firewall() { check_gatekeeper() { # Check whitelist - if command -v is_whitelisted >/dev/null && is_whitelisted "gatekeeper"; then return; fi + if command -v is_whitelisted > /dev/null && is_whitelisted "gatekeeper"; then return; fi # Check Gatekeeper status if command -v spctl > /dev/null 2>&1; then local gk_status=$(spctl --status 2> /dev/null || echo "") @@ -145,7 +145,7 @@ check_gatekeeper() { check_sip() { # Check whitelist - if command -v is_whitelisted >/dev/null && is_whitelisted "check_sip"; then return; fi + if command -v is_whitelisted > /dev/null && is_whitelisted "check_sip"; then return; fi # Check System Integrity Protection if command -v csrutil > /dev/null 2>&1; then local sip_status=$(csrutil status 2> /dev/null || echo "") @@ -209,7 +209,7 @@ is_cache_valid() { check_homebrew_updates() { # Check whitelist - if command -v is_whitelisted >/dev/null && is_whitelisted "check_brew_updates"; then return; fi + if command -v is_whitelisted > /dev/null && is_whitelisted "check_brew_updates"; then return; fi if ! command -v brew > /dev/null 2>&1; then return fi @@ -337,7 +337,7 @@ check_appstore_updates() { check_macos_update() { # Check whitelist - if command -v is_whitelisted >/dev/null && is_whitelisted "check_macos_updates"; then return; fi + if command -v is_whitelisted > /dev/null && is_whitelisted "check_macos_updates"; then return; fi local spinner_started=false if [[ -t 1 ]]; then printf " Checking macOS updates...\r" @@ -542,7 +542,7 @@ check_memory_usage() { check_login_items() { # Check whitelist - if command -v is_whitelisted >/dev/null && is_whitelisted "check_login_items"; then return; fi + if command -v is_whitelisted > /dev/null && is_whitelisted "check_login_items"; then return; fi local login_items_count=0 local -a login_items_list=() @@ -661,7 +661,7 @@ check_swap_usage() { check_brew_health() { # Check whitelist - if command -v is_whitelisted >/dev/null && is_whitelisted "check_brew_health"; then return; fi + if command -v is_whitelisted > /dev/null && is_whitelisted "check_brew_health"; then return; fi # Check Homebrew doctor if command -v brew > /dev/null 2>&1; then # Show spinner while running brew doctor diff --git a/lib/core/app_protection.sh b/lib/core/app_protection.sh index cf9f18d..7df261c 100755 --- a/lib/core/app_protection.sh +++ b/lib/core/app_protection.sh @@ -492,7 +492,7 @@ find_app_files() { # ============================================================================ # IDE-specific SDK and Toolchain directories # ============================================================================ - + # DevEco-Studio (HarmonyOS/OpenHarmony IDE by Huawei) if [[ "$app_name" =~ DevEco|deveco ]] || [[ "$bundle_id" =~ huawei.*deveco ]]; then [[ -d ~/DevEcoStudioProjects ]] && files_to_clean+=("$HOME/DevEcoStudioProjects") @@ -506,64 +506,64 @@ find_app_files() { [[ -d ~/.huawei ]] && files_to_clean+=("$HOME/.huawei") [[ -d ~/.ohos ]] && files_to_clean+=("$HOME/.ohos") fi - + # Android Studio if [[ "$app_name" =~ Android.*Studio|android.*studio ]] || [[ "$bundle_id" =~ google.*android.*studio|jetbrains.*android ]]; then [[ -d ~/AndroidStudioProjects ]] && files_to_clean+=("$HOME/AndroidStudioProjects") [[ -d ~/Library/Android ]] && files_to_clean+=("$HOME/Library/Android") [[ -d ~/.android ]] && files_to_clean+=("$HOME/.android") [[ -d ~/.gradle ]] && files_to_clean+=("$HOME/.gradle") - [[ -d ~/Library/Application\ Support/Google ]] && \ - while IFS= read -r -d '' dir; do files_to_clean+=("$dir"); done < <(find ~/Library/Application\ Support/Google -maxdepth 1 -name "AndroidStudio*" -print0 2>/dev/null) + [[ -d ~/Library/Application\ Support/Google ]] && + while IFS= read -r -d '' dir; do files_to_clean+=("$dir"); done < <(find ~/Library/Application\ Support/Google -maxdepth 1 -name "AndroidStudio*" -print0 2> /dev/null) fi - + # Xcode if [[ "$app_name" =~ Xcode|xcode ]] || [[ "$bundle_id" =~ apple.*xcode ]]; then [[ -d ~/Library/Developer ]] && files_to_clean+=("$HOME/Library/Developer") [[ -d ~/.Xcode ]] && files_to_clean+=("$HOME/.Xcode") fi - + # IntelliJ IDEA, PyCharm, WebStorm, etc. (JetBrains IDEs) if [[ "$bundle_id" =~ jetbrains ]] || [[ "$app_name" =~ IntelliJ|PyCharm|WebStorm|GoLand|RubyMine|PhpStorm|CLion|DataGrip|Rider ]]; then local ide_name="$app_name" - [[ -d ~/Library/Application\ Support/JetBrains ]] && \ - while IFS= read -r -d '' dir; do files_to_clean+=("$dir"); done < <(find ~/Library/Application\ Support/JetBrains -maxdepth 1 -name "${ide_name}*" -print0 2>/dev/null) - [[ -d ~/Library/Caches/JetBrains ]] && \ - while IFS= read -r -d '' dir; do files_to_clean+=("$dir"); done < <(find ~/Library/Caches/JetBrains -maxdepth 1 -name "${ide_name}*" -print0 2>/dev/null) - [[ -d ~/Library/Logs/JetBrains ]] && \ - while IFS= read -r -d '' dir; do files_to_clean+=("$dir"); done < <(find ~/Library/Logs/JetBrains -maxdepth 1 -name "${ide_name}*" -print0 2>/dev/null) + [[ -d ~/Library/Application\ Support/JetBrains ]] && + while IFS= read -r -d '' dir; do files_to_clean+=("$dir"); done < <(find ~/Library/Application\ Support/JetBrains -maxdepth 1 -name "${ide_name}*" -print0 2> /dev/null) + [[ -d ~/Library/Caches/JetBrains ]] && + while IFS= read -r -d '' dir; do files_to_clean+=("$dir"); done < <(find ~/Library/Caches/JetBrains -maxdepth 1 -name "${ide_name}*" -print0 2> /dev/null) + [[ -d ~/Library/Logs/JetBrains ]] && + while IFS= read -r -d '' dir; do files_to_clean+=("$dir"); done < <(find ~/Library/Logs/JetBrains -maxdepth 1 -name "${ide_name}*" -print0 2> /dev/null) fi - + # Unity if [[ "$app_name" =~ Unity|unity ]] || [[ "$bundle_id" =~ unity ]]; then [[ -d ~/.local/share/unity3d ]] && files_to_clean+=("$HOME/.local/share/unity3d") [[ -d ~/Library/Unity ]] && files_to_clean+=("$HOME/Library/Unity") fi - + # Unreal Engine if [[ "$app_name" =~ Unreal|unreal ]] || [[ "$bundle_id" =~ unrealengine|epicgames ]]; then [[ -d ~/Library/Application\ Support/Epic ]] && files_to_clean+=("$HOME/Library/Application Support/Epic") [[ -d ~/Documents/Unreal\ Projects ]] && files_to_clean+=("$HOME/Documents/Unreal Projects") fi - + # Visual Studio Code if [[ "$bundle_id" =~ microsoft.*vscode|visualstudio.*code ]]; then [[ -d ~/.vscode ]] && files_to_clean+=("$HOME/.vscode") [[ -d ~/.vscode-insiders ]] && files_to_clean+=("$HOME/.vscode-insiders") fi - + # Flutter if [[ "$app_name" =~ Flutter|flutter ]] || [[ "$bundle_id" =~ flutter ]]; then [[ -d ~/.pub-cache ]] && files_to_clean+=("$HOME/.pub-cache") [[ -d ~/flutter ]] && files_to_clean+=("$HOME/flutter") fi - + # Godot if [[ "$app_name" =~ Godot|godot ]] || [[ "$bundle_id" =~ godot ]]; then [[ -d ~/.local/share/godot ]] && files_to_clean+=("$HOME/.local/share/godot") [[ -d ~/Library/Application\ Support/Godot ]] && files_to_clean+=("$HOME/Library/Application Support/Godot") fi - + # Docker Desktop if [[ "$app_name" =~ Docker ]] || [[ "$bundle_id" =~ docker ]]; then [[ -d ~/.docker ]] && files_to_clean+=("$HOME/.docker") diff --git a/lib/core/base.sh b/lib/core/base.sh index 7ca6cfd..e89445e 100644 --- a/lib/core/base.sh +++ b/lib/core/base.sh @@ -304,7 +304,7 @@ cleanup_temp_files() { if [[ ${#MOLE_TEMP_DIRS[@]} -gt 0 ]]; then for file in "${MOLE_TEMP_DIRS[@]}"; do - [[ -d "$file" ]] && rm -rf "$file" 2> /dev/null || true # SAFE: cleanup_temp_files + [[ -d "$file" ]] && rm -rf "$file" 2> /dev/null || true # SAFE: cleanup_temp_files done fi diff --git a/lib/core/common.sh b/lib/core/common.sh index 7c05663..8da0cbb 100755 --- a/lib/core/common.sh +++ b/lib/core/common.sh @@ -89,7 +89,7 @@ remove_apps_from_dock() { fi # Execute Python helper to prune dock entries for the given app paths - python3 - "$@" << 'PY' 2>/dev/null || return 0 + python3 - "$@" << 'PY' 2> /dev/null || return 0 import os import plistlib import subprocess diff --git a/lib/core/file_ops.sh b/lib/core/file_ops.sh index 3697f0a..fe49a3c 100644 --- a/lib/core/file_ops.sh +++ b/lib/core/file_ops.sh @@ -100,7 +100,7 @@ safe_remove() { debug_log "Removing: $path" # Perform the deletion - if rm -rf "$path" 2> /dev/null; then # SAFE: safe_remove implementation + if rm -rf "$path" 2> /dev/null; then # SAFE: safe_remove implementation return 0 else [[ "$silent" != "true" ]] && log_error "Failed to remove: $path" @@ -135,7 +135,7 @@ safe_sudo_remove() { debug_log "Removing (sudo): $path" # Perform the deletion - if sudo rm -rf "$path" 2> /dev/null; then # SAFE: safe_sudo_remove implementation + if sudo rm -rf "$path" 2> /dev/null; then # SAFE: safe_sudo_remove implementation return 0 else log_error "Failed to remove (sudo): $path" diff --git a/lib/manage/whitelist.sh b/lib/manage/whitelist.sh index c99f68a..fd8a432 100755 --- a/lib/manage/whitelist.sh +++ b/lib/manage/whitelist.sh @@ -32,7 +32,7 @@ save_whitelist_patterns() { local -a patterns patterns=("$@") - + local config_file local header_text @@ -262,7 +262,7 @@ manage_whitelist() { manage_whitelist_categories() { local mode="$1" - + # Load currently enabled patterns from both sources load_whitelist "$mode" @@ -276,7 +276,7 @@ manage_whitelist_categories() { local items_source local menu_title local active_config_file - + if [[ "$mode" == "optimize" ]]; then items_source=$(get_optimize_whitelist_items) menu_title="Whitelist Manager – Select system checks to ignore" diff --git a/lib/uninstall/batch.sh b/lib/uninstall/batch.sh index 6bc3ff2..f477ef8 100755 --- a/lib/uninstall/batch.sh +++ b/lib/uninstall/batch.sh @@ -418,7 +418,7 @@ batch_uninstall_applications() { done done if [[ ${#removed_paths[@]} -gt 0 ]]; then - remove_apps_from_dock "${removed_paths[@]}" 2>/dev/null || true + remove_apps_from_dock "${removed_paths[@]}" 2> /dev/null || true fi fi