forked from jaildesigner-jailgames/jaildoctors_dilemma
afegida carpeta tools/linter
This commit is contained in:
46
tools/linter/run_clang-tidy.sh
Normal file
46
tools/linter/run_clang-tidy.sh
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script para ejecutar clang-tidy recursivamente en todo el código fuente
|
||||
# Uso: ./run_clang-tidy.sh [--fix]
|
||||
# --fix: Aplica las correcciones automáticamente (opcional)
|
||||
|
||||
# Auto-detectar la ubicación del script y calcular rutas del proyecto
|
||||
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
PROJECT_DIR=$(cd "$SCRIPT_DIR/../.." && pwd)
|
||||
SOURCE_DIR="$PROJECT_DIR/source"
|
||||
BUILD_DIR="$PROJECT_DIR/build"
|
||||
|
||||
# Detectar si se pasó el parámetro --fix
|
||||
FIX_FLAG=""
|
||||
if [[ "$1" == "--fix" ]]; then
|
||||
FIX_FLAG="--fix"
|
||||
echo "Modo: Aplicando correcciones automáticamente (--fix)"
|
||||
else
|
||||
echo "Modo: Solo análisis (sin --fix)"
|
||||
fi
|
||||
echo
|
||||
|
||||
# Verificar que los directorios existen
|
||||
if [[ ! -d "$SOURCE_DIR" ]]; then
|
||||
echo "Error: El directorio source/ no existe en: $SOURCE_DIR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -d "$BUILD_DIR" ]]; then
|
||||
echo "Error: El directorio build/ no existe en: $BUILD_DIR"
|
||||
echo "Ejecuta primero: cmake -B build && cmake --build build"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Proyecto: $PROJECT_DIR"
|
||||
echo "Fuentes: $SOURCE_DIR"
|
||||
echo "Build: $BUILD_DIR"
|
||||
echo
|
||||
|
||||
# Procesar todos los archivos C++ recursivamente desde source/
|
||||
echo "=== Escaneando recursivamente source/ ==="
|
||||
find "$SOURCE_DIR" \( -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \) -print0 | \
|
||||
xargs -0 -P4 -I{} bash -c 'echo "Procesando: {}"; clang-tidy {} -p '"$BUILD_DIR"' '"$FIX_FLAG"
|
||||
|
||||
echo
|
||||
echo "¡Proceso completado para todos los archivos!"
|
||||
Reference in New Issue
Block a user