#!/bin/bash
# Test PHPCS configuration for Comments Press Zone
# This script verifies that all false positives are properly suppressed

echo "========================================"
echo "Running PHPCS on Comments Press Zone"
echo "========================================"
echo ""

# Check if phpcs is available
if ! command -v phpcs &> /dev/null; then
    echo "❌ ERROR: phpcs not found. Please install PHP_CodeSniffer."
    echo "   Install globally: composer global require squizlabs/php_codesniffer"
    echo "   Or use: npx phpcs (if installed via npm)"
    exit 1
fi

# Run PHPCS with our configuration
echo "Testing with phpcs.xml.dist configuration..."
echo ""

phpcs --standard=phpcs.xml.dist \
    --extensions=php \
    --ignore=*/node_modules/*,*/vendor/*,*/build/*,*/admin/assets/* \
    includes/ \
    templates/ \
    uninstall.php \
    readme.txt

EXIT_CODE=$?

echo ""
echo "========================================"
if [ $EXIT_CODE -eq 0 ]; then
    echo "✅ SUCCESS: All checks passed!"
    echo "   No errors or warnings found."
else
    echo "⚠️  PHPCS found issues (exit code: $EXIT_CODE)"
    echo "   Review output above for details."
fi
echo "========================================"

exit $EXIT_CODE
