Skip to content

Commit 9d57eb2

Browse files
cdeckerclaude
andcommitted
ci: Fix shellcheck warnings in coverage scripts
Address all shellcheck linting warnings: - SC2207: Replace array assignment with mapfile -t - SC2086: Add quotes to prevent word splitting - SC2064: Use single quotes in trap command - SC2004: Remove unnecessary ${} in arithmetic contexts All scripts now pass shellcheck validation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
1 parent 453e192 commit 9d57eb2

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

contrib/coverage/cleanup-corrupt-profraw.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fi
1212
echo "Scanning for corrupt profraw files in: $COVERAGE_DIR"
1313

1414
# Find all profraw files
15-
PROFRAW_FILES=($(find "$COVERAGE_DIR" -name "*.profraw" 2>/dev/null || true))
15+
mapfile -t PROFRAW_FILES < <(find "$COVERAGE_DIR" -name "*.profraw" 2>/dev/null || true)
1616

1717
if [ ${#PROFRAW_FILES[@]} -eq 0 ]; then
1818
echo "No .profraw files found"

contrib/coverage/collect-coverage.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ OUTPUT="${2:-coverage/merged.profdata}"
88
echo "Collecting coverage from: $COVERAGE_DIR"
99

1010
# Find all profraw files
11-
PROFRAW_FILES=($(find "$COVERAGE_DIR" -name "*.profraw" 2>/dev/null || true))
11+
mapfile -t PROFRAW_FILES < <(find "$COVERAGE_DIR" -name "*.profraw" 2>/dev/null || true)
1212

1313
if [ ${#PROFRAW_FILES[@]} -eq 0 ]; then
1414
echo "ERROR: No .profraw files found in $COVERAGE_DIR"
@@ -75,7 +75,7 @@ mkdir -p "$(dirname "$OUTPUT")"
7575
BATCH_SIZE=500
7676
TOTAL_FILES=${#VALID_FILES[@]}
7777

78-
if [ $TOTAL_FILES -le $BATCH_SIZE ]; then
78+
if [ "$TOTAL_FILES" -le "$BATCH_SIZE" ]; then
7979
# Small enough to merge in one go
8080
echo "Merging ${TOTAL_FILES} files..."
8181
llvm-profdata merge -sparse "${VALID_FILES[@]}" -o "$OUTPUT"
@@ -85,16 +85,16 @@ else
8585

8686
# Create temp directory for intermediate files
8787
TEMP_DIR=$(mktemp -d "${TMPDIR:-/tmp}/profdata-merge.XXXXXX")
88-
trap "rm -rf '$TEMP_DIR'" EXIT
88+
trap 'rm -rf "$TEMP_DIR"' EXIT
8989

9090
BATCH_NUM=0
9191
INTERMEDIATE_FILES=()
9292

9393
# Merge files in batches
94-
for ((i=0; i<$TOTAL_FILES; i+=$BATCH_SIZE)); do
94+
for ((i=0; i<TOTAL_FILES; i+=BATCH_SIZE)); do
9595
BATCH_NUM=$((BATCH_NUM + 1))
9696
END=$((i + BATCH_SIZE))
97-
if [ $END -gt $TOTAL_FILES ]; then
97+
if [ "$END" -gt "$TOTAL_FILES" ]; then
9898
END=$TOTAL_FILES
9999
fi
100100

contrib/coverage/generate-coverage-report.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ fi
1313

1414
# Get all binaries from Makefile (includes plugins, tools, test binaries)
1515
echo "Discovering instrumented binaries from Makefile..."
16-
BINARIES=($(make -qp 2>/dev/null | awk '/^ALL_PROGRAMS :=/ {$1=$2=""; print}' | tr ' ' '\n' | grep -v '^$'))
17-
TEST_BINARIES=($(make -qp 2>/dev/null | awk '/^ALL_TEST_PROGRAMS :=/ {$1=$2=""; print}' | tr ' ' '\n' | grep -v '^$'))
16+
mapfile -t BINARIES < <(make -qp 2>/dev/null | awk '/^ALL_PROGRAMS :=/ {$1=$2=""; print}' | tr ' ' '\n' | grep -v '^$')
17+
mapfile -t TEST_BINARIES < <(make -qp 2>/dev/null | awk '/^ALL_TEST_PROGRAMS :=/ {$1=$2=""; print}' | tr ' ' '\n' | grep -v '^$')
1818

1919
# Combine all binaries
2020
ALL_BINARIES=("${BINARIES[@]}" "${TEST_BINARIES[@]}")

contrib/coverage/per-test-coverage-html.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ fi
1313

1414
# Get all binaries from Makefile (includes plugins, tools, test binaries)
1515
echo "Discovering instrumented binaries from Makefile..."
16-
BINARIES=($(make -qp 2>/dev/null | awk '/^ALL_PROGRAMS :=/ {$1=$2=""; print}' | tr ' ' '\n' | grep -v '^$'))
17-
TEST_BINARIES=($(make -qp 2>/dev/null | awk '/^ALL_TEST_PROGRAMS :=/ {$1=$2=""; print}' | tr ' ' '\n' | grep -v '^$'))
16+
mapfile -t BINARIES < <(make -qp 2>/dev/null | awk '/^ALL_PROGRAMS :=/ {$1=$2=""; print}' | tr ' ' '\n' | grep -v '^$')
17+
mapfile -t TEST_BINARIES < <(make -qp 2>/dev/null | awk '/^ALL_TEST_PROGRAMS :=/ {$1=$2=""; print}' | tr ' ' '\n' | grep -v '^$')
1818

1919
# Combine all binaries
2020
ALL_BINARIES=("${BINARIES[@]}" "${TEST_BINARIES[@]}")
@@ -38,7 +38,7 @@ if [ ${#ARGS[@]} -eq 0 ]; then
3838
fi
3939

4040
# Find all profdata files
41-
PROFDATA_FILES=($(find "$PROFDATA_DIR" -name "*.profdata" 2>/dev/null | sort))
41+
mapfile -t PROFDATA_FILES < <(find "$PROFDATA_DIR" -name "*.profdata" 2>/dev/null | sort)
4242

4343
if [ ${#PROFDATA_FILES[@]} -eq 0 ]; then
4444
echo "ERROR: No .profdata files found in $PROFDATA_DIR"

contrib/coverage/per-test-coverage.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ fi
1212

1313
# Get all binaries from Makefile (includes plugins, tools, test binaries)
1414
echo "Discovering instrumented binaries from Makefile..."
15-
BINARIES=($(make -qp 2>/dev/null | awk '/^ALL_PROGRAMS :=/ {$1=$2=""; print}' | tr ' ' '\n' | grep -v '^$'))
16-
TEST_BINARIES=($(make -qp 2>/dev/null | awk '/^ALL_TEST_PROGRAMS :=/ {$1=$2=""; print}' | tr ' ' '\n' | grep -v '^$'))
15+
mapfile -t BINARIES < <(make -qp 2>/dev/null | awk '/^ALL_PROGRAMS :=/ {$1=$2=""; print}' | tr ' ' '\n' | grep -v '^$')
16+
mapfile -t TEST_BINARIES < <(make -qp 2>/dev/null | awk '/^ALL_TEST_PROGRAMS :=/ {$1=$2=""; print}' | tr ' ' '\n' | grep -v '^$')
1717

1818
# Combine all binaries
1919
ALL_BINARIES=("${BINARIES[@]}" "${TEST_BINARIES[@]}")
@@ -39,7 +39,7 @@ fi
3939
mkdir -p "$OUTPUT_DIR"
4040

4141
# Find all test subdirectories
42-
TEST_DIRS=($(find "$COVERAGE_DIR" -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sort))
42+
mapfile -t TEST_DIRS < <(find "$COVERAGE_DIR" -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sort)
4343

4444
if [ ${#TEST_DIRS[@]} -eq 0 ]; then
4545
echo "ERROR: No test subdirectories found in $COVERAGE_DIR"
@@ -55,7 +55,7 @@ for test_dir in "${TEST_DIRS[@]}"; do
5555
echo -n " $test_name... "
5656

5757
# Find profraw files for this test
58-
PROFRAW_FILES=($(find "$test_dir" -name "*.profraw" 2>/dev/null || true))
58+
mapfile -t PROFRAW_FILES < <(find "$test_dir" -name "*.profraw" 2>/dev/null || true)
5959

6060
if [ ${#PROFRAW_FILES[@]} -eq 0 ]; then
6161
echo "no profraw files"

0 commit comments

Comments
 (0)