45 lines
1.0 KiB
Bash
Executable File
45 lines
1.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# scripts/check_banned_crates.sh
|
|
|
|
set -euo pipefail
|
|
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
|
|
echo "[check_banned_crates] scanning Cargo.toml files..."
|
|
|
|
FAILED=0
|
|
|
|
# Scan uniquement les Cargo.toml
|
|
while IFS= read -r file; do
|
|
if grep -nE '\b(anyhow|thiserror)\b' "$file"; then
|
|
echo "[check_banned_crates] banned crate found in $file"
|
|
FAILED=1
|
|
fi
|
|
done < <(find "$ROOT_DIR" \
|
|
-type f \
|
|
-name "Cargo.toml" \
|
|
-not -path "*/target/*" \
|
|
-not -path "*/.git/*" \
|
|
-not -path "*/.cargo/*")
|
|
|
|
# Optionnel : scan des imports Rust
|
|
echo "[check_banned_crates] scanning Rust sources..."
|
|
|
|
while IFS= read -r file; do
|
|
if grep -nE '\b(anyhow|thiserror)\b' "$file"; then
|
|
echo "[check_banned_crates] banned crate reference in $file"
|
|
FAILED=1
|
|
fi
|
|
done < <(find "$ROOT_DIR" \
|
|
-type f \
|
|
-name "*.rs" \
|
|
-not -path "*/target/*" \
|
|
-not -path "*/.git/*")
|
|
|
|
if [ "$FAILED" -ne 0 ]; then
|
|
echo "[check_banned_crates] FAILED"
|
|
exit 1
|
|
fi
|
|
|
|
echo "[check_banned_crates] ok"
|