#!/bin/bash

# Comprehensive snake_case to camelCase conversion script
# This script identifies all snake_case patterns that should be converted

echo "=== RateRight App Snake Case Analysis ==="
echo "Analyzing source files for snake_case patterns..."

# Create a temporary file for our findings
> /tmp/snake_case_analysis.txt

# Search for various snake_case patterns
echo "1. Searching for parameter prefixes (p_*)..." 
grep -rn "\bp_[a-z]" /home/ccuser/the-50-dollar-app/src --include="*.ts" --include="*.tsx" >> /tmp/snake_case_analysis.txt

echo "2. Searching for variable assignments with snake_case..."
grep -rn "[a-z]_[a-z].*=" /home/ccuser/the-50-dollar-app/src --include="*.ts" --include="*.tsx" | grep -v "created_at\|updated_at\|email_confirmed_at" >> /tmp/snake_case_analysis.txt

echo "3. Searching for object property access with snake_case..."
grep -rn "\.[a-z][a-z_]*_[a-z]" /home/ccuser/the-50-dollar-app/src --include="*.ts" --include="*.tsx" | grep -v "created_at\|updated_at\|email_confirmed_at" >> /tmp/snake_case_analysis.txt

echo "4. Searching for destructuring with snake_case..."
grep -rn "{.*[a-z]_[a-z].*}" /home/ccuser/the-50-dollar-app/src --include="*.ts" --include="*.tsx" >> /tmp/snake_case_analysis.txt

echo "Analysis complete. Results saved to /tmp/snake_case_analysis.txt"
echo "Found $(wc -l < /tmp/snake_case_analysis.txt) potential snake_case patterns"

# Show the most common patterns
echo "=== Most Common Snake Case Patterns ==="
cat /tmp/snake_case_analysis.txt | sort | uniq -c | sort -nr | head -20