refactor(iwyu): remove deprecated IWYU scripts for improved maintenance

This commit is contained in:
whaffman 2025-09-24 13:26:12 +00:00
parent 15d749eae9
commit 89e8dcd34d
2 changed files with 0 additions and 216 deletions

View File

@ -1,78 +0,0 @@
#!/bin/bash
set -e
PROJECT_ROOT="/workspace"
RESULTS_DIR="$PROJECT_ROOT/iwyu_results"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
echo -e "${BLUE}🔧 Reviewing IWYU fixes...${NC}"
if [ ! -d "$RESULTS_DIR" ]; then
echo -e "${RED}❌ No IWYU results found. Run './check_iwyu.sh' first.${NC}"
exit 1
fi
# Check if there are any result files
result_files=("$RESULTS_DIR"/*.iwyu)
if [ ! -f "${result_files[0]}" ]; then
echo -e "${YELLOW}⚠️ No IWYU result files found.${NC}"
exit 1
fi
echo -e "${BLUE}💡 IWYU Analysis Results - Manual Review Required${NC}"
echo -e "${YELLOW}Note: Automatic fixing requires careful review before applying changes.${NC}\n"
files_with_issues=0
for result_file in "$RESULTS_DIR"/*.iwyu; do
if [ -f "$result_file" ]; then
filename=$(basename "$result_file" .iwyu)
# Check if this file has suggestions
if grep -q "should add these lines:\|should remove these lines:" "$result_file"; then
((files_with_issues++))
echo -e "${BLUE}=== $filename.cpp ===${NC}"
# Show additions
if grep -q "should add these lines:" "$result_file"; then
echo -e "${GREEN}📥 Suggested additions:${NC}"
sed -n '/should add these lines:/,/^$/p' "$result_file" | grep -v "should add these lines:" | head -20
echo ""
fi
# Show removals
if grep -q "should remove these lines:" "$result_file"; then
echo -e "${RED}📤 Suggested removals:${NC}"
sed -n '/should remove these lines:/,/^$/p' "$result_file" | grep -v "should remove these lines:" | head -20
echo ""
fi
# Show full analysis (first 30 lines for context)
echo -e "${BLUE}📋 Full analysis:${NC}"
head -30 "$result_file"
echo -e "${YELLOW}... (see $result_file for complete output)${NC}"
echo -e "${BLUE}${'='*60}${NC}\n"
fi
fi
done
if [ $files_with_issues -eq 0 ]; then
echo -e "${GREEN}🎉 No issues found in any analyzed files!${NC}"
else
echo -e "${YELLOW}📊 Summary: $files_with_issues files have suggested changes${NC}"
echo -e "${BLUE}💡 Tips for applying fixes:${NC}"
echo -e " • Review each suggestion carefully"
echo -e " • Test compilation after each change"
echo -e " • Some suggestions might be false positives"
echo -e " • Consider project-specific header policies"
echo ""
echo -e "${BLUE}🗂️ Detailed results available in: $RESULTS_DIR${NC}"
fi

View File

@ -1,138 +0,0 @@
#!/bin/bash
# Safe automatic IWYU fix with build system validation
# This version applies fixes and validates using your actual build system
# Detect project root
if [ -d "/workspace" ]; then
PROJECT_ROOT="/workspace"
else
PROJECT_ROOT="$(pwd)"
fi
RESULTS_DIR="$PROJECT_ROOT/iwyu_results"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
echo -e "${BLUE}🔧 Safe IWYU Auto-Fix with Build Validation${NC}"
echo -e "${YELLOW}⚠️ This will apply fixes one file at a time and validate with your build system${NC}"
if [ ! -d "$RESULTS_DIR" ]; then
echo -e "${RED}❌ No IWYU results found. Run './check_iwyu.sh' first.${NC}"
exit 1
fi
# Make sure we can build first
echo -e "${BLUE}🔍 Testing initial build...${NC}"
if ! make -j$(nproc) release >/dev/null 2>&1; then
echo -e "${RED}❌ Project doesn't build currently. Fix build issues first.${NC}"
exit 1
fi
echo -e "${GREEN}✅ Initial build successful${NC}"
files_fixed=0
files_processed=0
# Process each .iwyu result file
for result_file in "$RESULTS_DIR"/*.iwyu; do
[ ! -f "$result_file" ] && continue
# Get the corresponding source file
base_name=$(basename "$result_file" .iwyu)
source_file=""
# Find the actual source file
while IFS= read -r -d '' file; do
if [[ "$(basename "$file" .cpp)" == "$base_name" ]]; then
source_file="$file"
break
fi
done < <(find "$PROJECT_ROOT/webserv" -name "*.cpp" -print0)
if [ -z "$source_file" ]; then
continue
fi
((files_processed++))
relative_path="${source_file#$PROJECT_ROOT/}"
echo -e "\n${BLUE}[$files_processed] Processing: $relative_path${NC}"
# Check if there are actual suggestions
if ! grep -q "should add these lines:" "$result_file"; then
echo -e "${GREEN} ✅ No additions needed${NC}"
continue
fi
# Create backup
backup_file="${source_file}.backup"
cp "$source_file" "$backup_file"
# Extract and apply only the additions (safer than removals)
additions_made=false
# Get the lines to add and store in temp file to avoid subshell issues
temp_includes=$(mktemp)
awk '/should add these lines:/{flag=1; next} /should remove these lines:|^$/{flag=0} flag && /^#include/{print}' "$result_file" > "$temp_includes"
# Process each include line
while IFS= read -r include_line; do
[ -z "$include_line" ] && continue
# Clean up the line (remove any trailing whitespace/comments after //)
clean_include=$(echo "$include_line" | sed 's|//.*$||' | sed 's/[[:space:]]*$//')
# Check if this exact include is already present (be more strict)
if grep -F "$clean_include" "$source_file" >/dev/null; then
echo -e "${YELLOW} ~ Already present: $clean_include${NC}"
continue
fi
# Add the include after the first existing #include
if sed -i "1,/^#include/ { /^#include/ a\\
$include_line
}" "$source_file"; then
echo -e "${GREEN} + Added: $include_line${NC}"
additions_made=true
fi
done < "$temp_includes"
rm -f "$temp_includes"
if [ "$additions_made" = true ]; then
# Test build with changes
echo -e "${BLUE} 🔨 Testing build...${NC}"
if make -j$(nproc) release >/dev/null 2>&1; then
echo -e "${GREEN} ✅ Build successful with changes${NC}"
rm "$backup_file"
((files_fixed++))
else
echo -e "${RED} ❌ Build failed, reverting changes${NC}"
mv "$backup_file" "$source_file"
fi
else
echo -e "${GREEN} ✅ No new includes to add${NC}"
rm "$backup_file"
fi
done
echo -e "\n${BLUE}📊 Safe Auto-fix Summary:${NC}"
echo -e "Files processed: $files_processed"
echo -e "Files successfully modified: $files_fixed"
if [ $files_fixed -gt 0 ]; then
echo -e "${GREEN}🎉 Applied $files_fixed successful fixes!${NC}"
echo -e "${BLUE}💡 Next steps:${NC}"
echo -e " • Review changes: ${BLUE}git diff${NC}"
echo -e " • Run full test: ${BLUE}make clean && make all${NC}"
echo -e " • Commit: ${BLUE}git add -A && git commit -m 'fix: add missing includes (IWYU)'${NC}"
else
echo -e "${GREEN}🎉 No fixes needed - all includes are already optimal!${NC}"
fi
exit 0