721721 local first=true
722722 if [[ ${# VALIDATION_RESULTS[@]} -gt 0 ]]; then
723723 for result in " ${VALIDATION_RESULTS[@]} " ; do
724+ # Skip empty results
725+ [[ -z " $result " ]] && continue
726+
724727 IFS=' |' read -r component check status message details <<< " $result"
725728
726729 [[ " $first " == " true" ]] && first=false || echo " ," >> " $OUTPUT_FILE "
@@ -736,11 +739,15 @@ EOF
736739 }
737740EOF
738741
739- (( total_checks++ ))
742+ # Safe arithmetic operations
743+ total_checks=$(( total_checks + 1 ))
740744 case " $status " in
741- pass) (( passed_checks++ )) ;;
742- fail) (( failed_checks++ )) ;;
743- warn) (( warn_checks++ )) ;;
745+ pass) passed_checks=$(( passed_checks + 1 )) ;;
746+ fail) failed_checks=$(( failed_checks + 1 )) ;;
747+ warn) warn_checks=$(( warn_checks + 1 )) ;;
748+ * )
749+ echo " Warning: Unknown validation status '$status ' for $component /$check " >&2
750+ ;;
744751 esac
745752 done
746753 fi
@@ -769,18 +776,32 @@ print_summary() {
769776 local failed_checks=0
770777 local warn_checks=0
771778
779+ # Debug: Show validation results array status
780+ log DEBUG " Processing ${# VALIDATION_RESULTS[@]} validation results"
781+
772782 if [[ ${# VALIDATION_RESULTS[@]} -gt 0 ]]; then
773783 for result in " ${VALIDATION_RESULTS[@]} " ; do
784+ # Skip empty results
785+ [[ -z " $result " ]] && continue
786+
774787 IFS=' |' read -r component check status message details <<< " $result"
775- (( total_checks++ ))
788+
789+ # Safe arithmetic operations
790+ total_checks=$(( total_checks + 1 ))
776791 case " $status " in
777- pass) (( passed_checks++ )) ;;
778- fail) (( failed_checks++ )) ;;
779- warn) (( warn_checks++ )) ;;
792+ pass) passed_checks=$(( passed_checks + 1 )) ;;
793+ fail) failed_checks=$(( failed_checks + 1 )) ;;
794+ warn) warn_checks=$(( warn_checks + 1 )) ;;
795+ * )
796+ echo " Warning: Unknown validation status '$status ' for $component /$check " >&2
797+ ;;
780798 esac
781799 done
782800 fi
783801
802+ # Debug: Show final counts
803+ log DEBUG " Validation counts - Total: $total_checks , Passed: $passed_checks , Failed: $failed_checks , Warnings: $warn_checks "
804+
784805 local success_rate=0
785806 if [[ $total_checks -gt 0 ]]; then
786807 success_rate=$(( (passed_checks * 100 ) / total_checks ))
@@ -995,6 +1016,12 @@ main() {
9951016
9961017 generate_report
9971018 print_summary
1019+ local exit_code=$?
1020+
1021+ # Debug: Show final exit code
1022+ log DEBUG " print_summary returned exit code: $exit_code "
1023+
1024+ exit $exit_code
9981025}
9991026
10001027# Run main function with all arguments
0 commit comments