#!/usr/bin/env bash # check_file_sizes.sh — fails CI if any source file exceeds 500 lines # Usage: bash scripts/check_file_sizes.sh set -euo pipefail MAX_LINES=500 FAILED=0 while IFS= read -r -d '' file; do lines=$(wc -l < "$file") if [[ $lines -gt $MAX_LINES ]]; then echo "FAIL: $file has $lines lines (limit: $MAX_LINES)" FAILED=1 fi done < <(find . \ \( -name "*.py" -o -name "*.tsx" -o -name "*.jsx" -o -name "*.ts" \) \ -not -path "./.git/*" \ -not -path "./node_modules/*" \ -not -path "./.next/*" \ -not -path "./__pycache__/*" \ -not -name "ml_pipeline.py" \ -not -name "ml_status.py" \ -print0) if [[ $FAILED -eq 1 ]]; then echo "" echo "One or more files exceed the $MAX_LINES-line limit." echo "Split large files into focused modules." exit 1 fi echo "All files within $MAX_LINES-line limit."