From b61d16dc7e09db71cb599dab86977d92f3ad416b Mon Sep 17 00:00:00 2001 From: cschantz Date: Fri, 9 Jan 2026 18:09:18 -0500 Subject: [PATCH] Fix DEP check false positives for detect_control_panel detect_control_panel is in system-detect.sh, not domain-discovery.sh Check now properly validates that system-detect.sh is sourced --- tools/toolkit-qa-check.sh | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/tools/toolkit-qa-check.sh b/tools/toolkit-qa-check.sh index dc6151c..bc14f6b 100755 --- a/tools/toolkit-qa-check.sh +++ b/tools/toolkit-qa-check.sh @@ -1845,17 +1845,35 @@ while IFS=: read -r file line_num line_content; do if [[ "$func_used" =~ (print_|confirm_action) ]]; then required_lib="common-functions.sh" + if ! grep -q "source.*$required_lib" "$file" 2>/dev/null; then + echo "HIGH|$file|$line_num|[DEP] Using $func_used without sourcing $required_lib" + echo " Risk: Function undefined error at runtime" + echo " Fix: Add 'source \$(dirname \$0)/../lib/$required_lib' at top of script" + count_issue "HIGH" + ((count++)) + [ "$count" -ge 10 ] && break + fi + elif [[ "$func_used" =~ detect_control_panel ]]; then + # detect_control_panel is in system-detect.sh + if ! grep -q "source.*system-detect\.sh" "$file" 2>/dev/null; then + echo "HIGH|$file|$line_num|[DEP] Using $func_used without sourcing system-detect.sh" + echo " Risk: Function undefined error at runtime" + echo " Fix: Add 'source \$(dirname \$0)/../lib/system-detect.sh' at top of script" + count_issue "HIGH" + ((count++)) + [ "$count" -ge 10 ] && break + fi else + # Domain/user functions are in domain-discovery.sh required_lib="domain-discovery.sh" - fi - - if ! grep -q "source.*$required_lib" "$file" 2>/dev/null; then - echo "HIGH|$file|$line_num|[DEP] Using $func_used without sourcing $required_lib" - echo " Risk: Function undefined error at runtime" - echo " Fix: Add 'source \$(dirname \$0)/../lib/$required_lib' at top of script" - count_issue "HIGH" - ((count++)) - [ "$count" -ge 10 ] && break + if ! grep -q "source.*$required_lib" "$file" 2>/dev/null; then + echo "HIGH|$file|$line_num|[DEP] Using $func_used without sourcing $required_lib" + echo " Risk: Function undefined error at runtime" + echo " Fix: Add 'source \$(dirname \$0)/../lib/$required_lib' at top of script" + count_issue "HIGH" + ((count++)) + [ "$count" -ge 10 ] && break + fi fi done < <(grep -rnE "\b($common_funcs|$detect_funcs)\b" "$TOOLKIT_PATH" --include="*.sh" --exclude="common-functions.sh" --exclude="domain-discovery.sh" --exclude="system-detect.sh" 2>/dev/null | head -100)