diff --git a/scripts/digital_wellbeing/pacman/pacman_wrapper.sh b/scripts/digital_wellbeing/pacman/pacman_wrapper.sh index 0cca9e1..3b00698 100755 --- a/scripts/digital_wellbeing/pacman/pacman_wrapper.sh +++ b/scripts/digital_wellbeing/pacman/pacman_wrapper.sh @@ -2,6 +2,8 @@ # filepath: pacman-wrapper.sh # A helpful wrapper for Arch Linux's pacman package manager +# shellcheck disable=SC2317 # Many functions are called indirectly + # Colors RED='\033[0;31m' GREEN='\033[0;32m' @@ -18,6 +20,7 @@ declare -a WHITELISTED_NAMES_LIST=() declare -a GREYLISTED_KEYWORDS_LIST=() POLICY_LISTS_LOADED=0 +# shellcheck disable=SC2317 # Function is called indirectly load_policy_lists() { if [[ $POLICY_LISTS_LOADED -eq 1 ]]; then return @@ -187,6 +190,7 @@ function display_operation() { } # Helper: return 0 if the given package name is blocked by policy +# shellcheck disable=SC2317 # Function is called indirectly function is_blocked_package_name() { load_policy_lists local normalized="${1,,}" diff --git a/scripts/lib/common.sh b/scripts/lib/common.sh index a946a52..e0cd9f8 100644 --- a/scripts/lib/common.sh +++ b/scripts/lib/common.sh @@ -135,6 +135,7 @@ handle_arg_help_or_unknown() { return 1 # Not a flag, let caller handle it ;; esac + # shellcheck disable=SC2317 return 0 } diff --git a/scripts/meta/shell_check.sh b/scripts/meta/shell_check.sh index 8196c37..658e1cc 100755 --- a/scripts/meta/shell_check.sh +++ b/scripts/meta/shell_check.sh @@ -256,7 +256,8 @@ run_linters() { log_info "Running shellcheck..." local sc_out="$TMPDIR/shellcheck.txt" if is_cmd shellcheck; then - if ! shellcheck -x -S style "${FILES[@]}" > "$sc_out" 2>&1; then + # Exclude SC1091 (not following sourced files) as it's expected in many scripts + if ! shellcheck -x -S style -e SC1091 "${FILES[@]}" > "$sc_out" 2>&1; then issues=$((issues + 1)) fi else diff --git a/scripts/utils/generate_study_materials.sh b/scripts/utils/generate_study_materials.sh index dea352e..3e1019a 100755 --- a/scripts/utils/generate_study_materials.sh +++ b/scripts/utils/generate_study_materials.sh @@ -522,10 +522,12 @@ if [ -d "$PER_LANG_DIR" ]; then *) display_lang="$lang" ;; esac - echo "### $display_lang Keywords" >> "$DOCS_FILE" - echo "" >> "$DOCS_FILE" - echo "| Keyword | Count | Documentation |" >> "$DOCS_FILE" - echo "|---------|-------|---------------|" >> "$DOCS_FILE" + { + echo "### $display_lang Keywords" + echo "" + echo "| Keyword | Count | Documentation |" + echo "|---------|-------|---------------|" + } >> "$DOCS_FILE" head -"$TOP_N" "$keyword_file" | while read -r count term; do [ -z "$term" ] && continue @@ -560,10 +562,12 @@ if [ -d "$PER_LANG_DIR" ]; then *) display_lang="$lang" ;; esac - echo "### $display_lang Functions" >> "$DOCS_FILE" - echo "" >> "$DOCS_FILE" - echo "| Function | Count | Documentation |" >> "$DOCS_FILE" - echo "|----------|-------|---------------|" >> "$DOCS_FILE" + { + echo "### $display_lang Functions" + echo "" + echo "| Function | Count | Documentation |" + echo "|----------|-------|---------------|" + } >> "$DOCS_FILE" head -"$TOP_N" "$func_file" | while read -r count term; do [ -z "$term" ] && continue @@ -598,10 +602,12 @@ if [ -d "$PER_LANG_DIR" ]; then *) display_lang="$lang" ;; esac - echo "### $display_lang" >> "$DOCS_FILE" - echo "" >> "$DOCS_FILE" - echo "| Import | Count | Documentation |" >> "$DOCS_FILE" - echo "|--------|-------|---------------|" >> "$DOCS_FILE" + { + echo "### $display_lang" + echo "" + echo "| Import | Count | Documentation |" + echo "|--------|-------|---------------|" + } >> "$DOCS_FILE" head -20 "$import_file" | while read -r count import; do [ -z "$import" ] && continue @@ -623,10 +629,12 @@ else echo -e "${YELLOW}No per-language files found, using combined analysis${NC}" if [ -f "$RESULTS_DIR/grep_keywords.txt" ]; then - echo "## Language Keywords" >> "$DOCS_FILE" - echo "" >> "$DOCS_FILE" - echo "| Keyword | Count | Documentation |" >> "$DOCS_FILE" - echo "|---------|-------|---------------|" >> "$DOCS_FILE" + { + echo "## Language Keywords" + echo "" + echo "| Keyword | Count | Documentation |" + echo "|---------|-------|---------------|" + } >> "$DOCS_FILE" head -"$TOP_N" "$RESULTS_DIR/grep_keywords.txt" | while read -r count term; do [ -z "$term" ] && continue @@ -637,10 +645,12 @@ else fi if [ -f "$RESULTS_DIR/grep_function_calls.txt" ]; then - echo "## Function/Method Calls" >> "$DOCS_FILE" - echo "" >> "$DOCS_FILE" - echo "| Function | Count | Documentation |" >> "$DOCS_FILE" - echo "|----------|-------|---------------|" >> "$DOCS_FILE" + { + echo "## Function/Method Calls" + echo "" + echo "| Function | Count | Documentation |" + echo "|----------|-------|---------------|" + } >> "$DOCS_FILE" head -"$TOP_N" "$RESULTS_DIR/grep_function_calls.txt" | while read -r count term; do [ -z "$term" ] && continue @@ -652,10 +662,12 @@ else fi if [ -f "$RESULTS_DIR/grep_imports.txt" ]; then - echo "## Imports/Includes" >> "$DOCS_FILE" - echo "" >> "$DOCS_FILE" - echo "| Import | Count | Documentation |" >> "$DOCS_FILE" - echo "|--------|-------|---------------|" >> "$DOCS_FILE" + { + echo "## Imports/Includes" + echo "" + echo "| Import | Count | Documentation |" + echo "|--------|-------|---------------|" + } >> "$DOCS_FILE" head -20 "$RESULTS_DIR/grep_imports.txt" | while read -r count import; do [ -z "$import" ] && continue @@ -668,9 +680,11 @@ else fi fi -echo "" >> "$DOCS_FILE" -echo "---" >> "$DOCS_FILE" -echo "*Generated by analyze_repo.sh + generate_study_materials.sh*" >> "$DOCS_FILE" +{ + echo "" + echo "---" + echo "*Generated by analyze_repo.sh + generate_study_materials.sh*" +} >> "$DOCS_FILE" echo -e "${GREEN}Created: $DOCS_FILE${NC}" #==============================================================================