#!/usr/bin/env bash
source "$GIT_CONFIG/git.paths.conf"
set -euo pipefail

source "$(dirname "$0")/rules.engine.sh"
load_rules "$GIT_ROOT/config/rules.naming"

errors=0

check_no_underscores() {
    if [[ "${RULES[no_underscores]}" == "true" ]]; then
        while IFS= read -r f; do
            if [[ "$f" == *_* ]]; then
                echo "[NAMING ERROR] Underscore found: $f"
                errors=$((errors+1))
            fi
        done < <(find "$GIT_ROOT" -type f)
    fi
}

check_no_underscores

if (( errors > 0 )); then
    echo "[FAIL] Naming audit failed."
    exit 1
else
    echo "[OK] Naming audit passed."
fi

