3e336d4958
Refactor: Extract common code to shared library
...
Created scripts/lib/common.sh with shared functions:
- log_message(), log() - consistent logging with timestamps
- require_root() - root privilege checking with optional sudo re-exec
- get_actual_user(), get_actual_user_home() - handle SUDO_USER properly
- parse_interactive_args() - standard --interactive/-i and --help/-h handling
- notify() - cross-platform desktop notifications
- require_command(), ensure_dir() - common utility functions
- enable_service(), is_service_active() - systemd helpers
Refactored scripts to use common library:
- block_compulsive_opening.sh
- setup_pc_startup_monitor.sh
- setup_periodic_system.sh
- setup_thorium_startup.sh
- nvidia_troubleshoot.sh
- hosts/guard/setup_hosts_guard.sh
- hosts/guard/enforce-hosts.sh
Merged duplicate scripts:
- Created convert_video.sh (combined to_mp4.sh and to_webm.sh)
- Removed pdf_to_png.sh (was identical to pdf_to_image.sh)
Reduced duplication from 4.08% (48 clones) to 1.86% (26 clones)
2025-12-11 17:43:50 +01:00
4016cf8a34
Stricter duplicate detection: 5 lines, 25 tokens, 0% threshold
...
- Auto-installs jscpd if missing
- Blocks commit on any duplication detected
- Current repo has 48 clones that need refactoring
2025-12-11 17:33:35 +01:00
e4d414b746
Add duplicate code detection to pre-commit hook
...
Uses jscpd to detect code clones in shell scripts.
Blocks commit if duplication exceeds 5% threshold.
Suggests extracting common code to scripts/lib/common.sh.
2025-12-11 17:31:47 +01:00
dfe079c219
fix: improve pre-commit hook to avoid formatting loop
...
- Auto-fix with shfmt on staged files
- Run shellcheck validation directly instead of full shell_check.sh
- Avoids shfmt -d validation after auto-formatting (prevents .orig file loop)
- Ensures consistent formatting without blocking commits
2025-11-16 21:20:23 +01:00
53bd0fd60a
refactor: remove all skip-fmt flags and enforce all checks always
2025-11-16 20:55:39 +01:00
f9884270e4
fix: format pre-commit hook and root_bl9000.sh with shfmt
2025-11-16 20:48:41 +01:00
46fb79b262
feat: add auto-fix to pre-commit hook with --skip-fmt option
2025-11-16 20:40:34 +01:00
38b4214cfb
chore: enforce shell_check via tracked pre-commit hook
2025-11-01 16:02:58 +01:00