@@ -99,14 +99,17 @@ process_bep() {
9999
100100 # Extract target information
101101 if echo " $line " | jq -e ' .id.targetCompleted != null' > /dev/null 2>&1 ; then
102- local label=$( echo " $line " | jq -r ' .id.targetCompleted.label // "unknown"' )
103- local success=$( echo " $line " | jq -r ' .completed.success // "false"' )
102+ local label
103+ label=$( echo " $line " | jq -r ' .id.targetCompleted.label // "unknown"' )
104+ local success
105+ success=$( echo " $line " | jq -r ' .completed.success // "false"' )
104106 local is_cached=false
105107
106108 # Check if the target was cached
107109 if echo " $line " | jq -e ' .completed.outputGroup != null and (.completed.outputGroup[] | select(.name == "bazel-out") | .fileSets[] | select(.id != null))' > /dev/null 2>&1 ; then
108110 # If it has output files but doesn't have actionExecuted, it's likely cached
109111 if ! echo " $line " | jq -e ' .completed.actionExecuted != null' > /dev/null 2>&1 ; then
112+ # is_cached flag set for potential future use
110113 is_cached=true
111114 (( cached_count++ ))
112115 fi
@@ -118,7 +121,8 @@ process_bep() {
118121 else
119122 (( fail_count++ ))
120123 # Get failure details with proper highlighting
121- local errors=$( echo " $line " | jq -r ' .completed.failureDetail.message // "Unknown error"' )
124+ local errors
125+ errors=$( echo " $line " | jq -r ' .completed.failureDetail.message // "Unknown error"' )
122126 failure_details+=" ### ❌ Failed: $label
123127\`\`\` diff
124128- ERROR: $errors
@@ -128,7 +132,8 @@ process_bep() {
128132 # Check for missing dependency or deleted package errors
129133 if echo " $errors " | grep -q " no such target\|no such package\|Package is considered deleted" ; then
130134 # Extract relevant part of the error message
131- local error_detail=$( echo " $errors " | grep -o " '[^']*'\|Package [^:]*" | head -1)
135+ local error_detail
136+ error_detail=$( echo " $errors " | grep -o " '[^']*'\|Package [^:]*" | head -1)
132137 failure_details+=" **🔍 Possible Fix:** $error_detail might be missing, renamed, or deleted. Add it to --deleted_packages flag if it's intentionally deleted.
133138
134139"
@@ -138,8 +143,11 @@ process_bep() {
138143
139144 # Also check for configured targets
140145 if echo " $line " | jq -e ' .id.configured != null' > /dev/null 2>&1 ; then
141- local label=$( echo " $line " | jq -r ' .id.configured.targetLabel // "unknown"' )
142- if [[ ! " ${successful_targets[*]} " =~ " ${label} " ]]; then
146+ local label
147+ label=$( echo " $line " | jq -r ' .id.configured.targetLabel // "unknown"' )
148+ # Using a simple pattern match to check if the label is in the array
149+ # Avoiding regex comparison which causes shellcheck warning
150+ if [[ ! " ${successful_targets[*]} " == * " $label " * ]]; then
143151 # Only add if it's not already counted
144152 (( success_count++ ))
145153 successful_targets+=(" $label " )
@@ -148,15 +156,19 @@ process_bep() {
148156
149157 # Extract skipped targets
150158 if echo " $line " | jq -e ' .id.targetSkipped != null' > /dev/null 2>&1 ; then
151- local label=$( echo " $line " | jq -r ' .id.targetSkipped.label // "unknown"' )
159+ local label
160+ label=$( echo " $line " | jq -r ' .id.targetSkipped.label // "unknown"' )
152161 (( skip_count++ ))
153162 fi
154163
155164 # Extract test results if available
156165 if echo " $line " | jq -e ' .id.testResult != null' > /dev/null 2>&1 ; then
157- local test_label=$( echo " $line " | jq -r ' .id.testResult.label // "unknown"' )
158- local test_status=$( echo " $line " | jq -r ' .testResult.status // "UNKNOWN"' )
159- local test_time=$( echo " $line " | jq -r ' .testResult.testActionDurationMillis // 0' )
166+ local test_label
167+ test_label=$( echo " $line " | jq -r ' .id.testResult.label // "unknown"' )
168+ local test_status
169+ test_status=$( echo " $line " | jq -r ' .testResult.status // "UNKNOWN"' )
170+ local test_time
171+ test_time=$( echo " $line " | jq -r ' .testResult.testActionDurationMillis // 0' )
160172
161173 # Default to 1.0s if no duration available
162174 if [ " $test_time " -eq 0 ]; then
@@ -178,8 +190,8 @@ process_bep() {
178190 fi
179191
180192 # Always include test duration in the performance tracking
181- slowest_tests[$ slowest_count ]=" $test_label "
182- slowest_times[$ slowest_count ]=" $test_time "
193+ slowest_tests[slowest_count]=" $test_label "
194+ slowest_times[slowest_count]=" $test_time "
183195 (( slowest_count++ ))
184196
185197 if [ " $test_status " != " PASSED" ]; then
@@ -206,7 +218,8 @@ process_bep() {
206218 # Add stack trace if available
207219 if echo " $line " | jq -e ' has("testResult") and .testResult | has("testActionOutput") and .testResult.testActionOutput != null' > /dev/null 2>&1 ; then
208220 if echo " $line " | jq -e ' .testResult.testActionOutput[] | select(.name == "test.log") | .uri' > /dev/null 2>&1 ; then
209- local log_uri=$( echo " $line " | jq -r ' .testResult.testActionOutput[] | select(.name == "test.log") | .uri' )
221+ local log_uri
222+ log_uri=$( echo " $line " | jq -r ' .testResult.testActionOutput[] | select(.name == "test.log") | .uri' )
210223 failure_details+=" [View Full Test Log]($log_uri )
211224
212225"
@@ -218,7 +231,7 @@ process_bep() {
218231
219232 # Calculate total build time
220233 local total_build_time=0
221- if [ $build_end_time -gt 0 ] && [ $build_start_time -gt 0 ]; then
234+ if [ " $build_end_time " -gt 0 ] && [ " $build_start_time " -gt 0 ]; then
222235 total_build_time=$(( (build_end_time - build_start_time) / 1000 ))
223236 fi
224237
@@ -275,12 +288,15 @@ process_bep() {
275288"
276289
277290 # First sort the tests by duration (longest first)
291+ # sorted_indexes is kept for potential future implementation of index tracking
292+ # or for maintaining references to original array positions
278293 local sorted_indexes=()
279294 local sorted_times=()
280295 local sorted_tests=()
281296
282297 # Create a temporary file to sort the data
283- local tmp_file=$( mktemp)
298+ local tmp_file
299+ tmp_file=$( mktemp)
284300
285301 # Populate the temp file with "time test_name" format for sorting
286302 for i in " ${! slowest_tests[@]} " ; do
@@ -300,7 +316,7 @@ process_bep() {
300316 for i in " ${! sorted_tests[@]} " ; do
301317 summary+=" - \` ${sorted_tests[$i]} \` : ${sorted_times[$i]} s
302318"
303- if [ $i -ge 9 ]; then # Show only top 10 slowest tests
319+ if [ " $i " -ge 9 ]; then # Show only top 10 slowest tests
304320 if [ ${# sorted_tests[@]} -gt 10 ]; then
305321 summary+=" - _...and $(( ${# sorted_tests[@]} - 10 )) more_
306322"
@@ -321,8 +337,7 @@ process_bep() {
321337"
322338
323339 # Sort the targets for better readability
324- IFS=$' \n ' successful_targets_sorted=($( sort <<< " ${successful_targets[*]}" ) )
325- unset IFS
340+ readarray -t successful_targets_sorted < <( printf ' %s\n' " ${successful_targets[@]} " | sort)
326341
327342 # Show all targets
328343 for target in " ${successful_targets_sorted[@]} " ; do
0 commit comments