Lint: clang-tidy --fix mecánico (trailing return, default member init, auto, enum size)
Pase automático de clang-tidy --fix sobre el conjunto de checks que son puro transform de sintaxis y no rompen API. Invocado con --format-style=none para que clang-tidy NO arrastre clang-format sobre las líneas tocadas (evita la regla NamespaceIndentation: All del .clang-format reformateando solo trozos del archivo). Checks aplicados: - modernize-use-trailing-return-type (193 hits): 'int foo()' → 'auto foo() -> int'. Estilo coherente con la convención del proyecto. - modernize-use-default-member-init (36 hits): inicialización de miembros pasa de la lista del constructor a la declaración. Reduce duplicación cuando hay varios constructores con los mismos defaults. - modernize-use-auto (6 hits): tipos largos sustituidos por auto donde el tipo es evidente del contexto (new T, dynamic_cast, etc). - modernize-use-starts-ends-with (2 hits): s.rfind(x) == 0 → s.starts_with(x), aprovechando C++20. - performance-enum-size (10 hits): enums pequeños declaran tipo subyacente (uint8_t / similar) para reducir tamaño y precisar layout. NO aplicado en este pase (riesgo de cambios semánticos o de API): - readability-identifier-naming (renames pueden romper callsites parciales) - readability-convert-member-functions-to-static (cambia firma) - readability-use-anyofallof (reescribe loops, side effects) - readability-function-cognitive-complexity (requiere refactor manual) - bugs reales (bugprone-*, clang-diagnostic-*) → uno a uno Cambios manuales asociados: - SDLManager::clear() ahora devuelve bool: propaga el resultado de beginFrame al caller para que Director::runFrameLoop salte draw+present cuando la swapchain no esté disponible (ventana minimizada). Antes la función ignoraba el [[nodiscard]] del beginFrame y los vértices se acumulaban en el batch sin nadie que los consumiera. - vector_text.cpp: borrada la línea suelta "// Test pre-commit hook" que quedó como cruft. clang-tidy crashea en LLVM 19.1 con performance-noexcept-move-constructor (recursión infinita en ExceptionSpecAnalyzer al procesar std::set); check deshabilitado en .clang-tidy con comentario explicativo. Build limpio, smoke test OK. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -16,7 +16,7 @@ namespace Effects {
|
||||
|
||||
// Helper: transformar point con rotación, scale i traslación
|
||||
// (Copiat de shape_renderer.cpp:12-34)
|
||||
static Vec2 transform_point(const Vec2& point, const Vec2& shape_centre, const Vec2& position, float angle, float scale) {
|
||||
static auto transform_point(const Vec2& point, const Vec2& shape_centre, const Vec2& position, float angle, float scale) -> Vec2 {
|
||||
// 1. Centrar el point respecte al centro de la shape
|
||||
float centered_x = point.x - shape_centre.x;
|
||||
float centered_y = point.y - shape_centre.y;
|
||||
@@ -320,7 +320,7 @@ void DebrisManager::draw() const {
|
||||
}
|
||||
}
|
||||
|
||||
Debris* DebrisManager::findFreeSlot() {
|
||||
auto DebrisManager::findFreeSlot() -> Debris* {
|
||||
for (auto& debris : debris_pool_) {
|
||||
if (!debris.active) {
|
||||
return &debris;
|
||||
@@ -329,9 +329,9 @@ Debris* DebrisManager::findFreeSlot() {
|
||||
return nullptr; // Pool ple
|
||||
}
|
||||
|
||||
Vec2 DebrisManager::computeExplosionDirection(const Vec2& p1,
|
||||
auto DebrisManager::computeExplosionDirection(const Vec2& p1,
|
||||
const Vec2& p2,
|
||||
const Vec2& centre_objecte) const {
|
||||
const Vec2& centre_objecte) const -> Vec2 {
|
||||
// 1. Calcular centro del segment
|
||||
float centro_seg_x = (p1.x + p2.x) / 2.0F;
|
||||
float centro_seg_y = (p1.y + p2.y) / 2.0F;
|
||||
@@ -372,7 +372,7 @@ void DebrisManager::reset() {
|
||||
}
|
||||
}
|
||||
|
||||
int DebrisManager::getActiveCount() const {
|
||||
auto DebrisManager::getActiveCount() const -> int {
|
||||
int count = 0;
|
||||
for (const auto& debris : debris_pool_) {
|
||||
if (debris.active) {
|
||||
|
||||
@@ -54,7 +54,7 @@ class DebrisManager {
|
||||
void reset();
|
||||
|
||||
// Obtenir número de fragments active
|
||||
[[nodiscard]] int getActiveCount() const;
|
||||
[[nodiscard]] auto getActiveCount() const -> int;
|
||||
|
||||
private:
|
||||
Rendering::Renderer* renderer_;
|
||||
@@ -67,10 +67,10 @@ class DebrisManager {
|
||||
std::array<Debris, MAX_DEBRIS> debris_pool_;
|
||||
|
||||
// Trobar primer slot inactiu
|
||||
Debris* findFreeSlot();
|
||||
auto findFreeSlot() -> Debris*;
|
||||
|
||||
// Calcular direcció de explosión (radial, des del centro hacia el segment)
|
||||
[[nodiscard]] Vec2 computeExplosionDirection(const Vec2& p1, const Vec2& p2, const Vec2& centre_objecte) const;
|
||||
[[nodiscard]] auto computeExplosionDirection(const Vec2& p1, const Vec2& p2, const Vec2& centre_objecte) const -> Vec2;
|
||||
};
|
||||
|
||||
} // namespace Effects
|
||||
|
||||
@@ -77,7 +77,7 @@ void FloatingScoreManager::reset() {
|
||||
}
|
||||
}
|
||||
|
||||
int FloatingScoreManager::getActiveCount() const {
|
||||
auto FloatingScoreManager::getActiveCount() const -> int {
|
||||
int count = 0;
|
||||
for (const auto& pf : pool_) {
|
||||
if (pf.active) {
|
||||
@@ -87,7 +87,7 @@ int FloatingScoreManager::getActiveCount() const {
|
||||
return count;
|
||||
}
|
||||
|
||||
FloatingScore* FloatingScoreManager::findFreeSlot() {
|
||||
auto FloatingScoreManager::findFreeSlot() -> FloatingScore* {
|
||||
for (auto& pf : pool_) {
|
||||
if (!pf.active) {
|
||||
return &pf;
|
||||
|
||||
@@ -37,7 +37,7 @@ class FloatingScoreManager {
|
||||
void reset();
|
||||
|
||||
// Obtenir número active (debug)
|
||||
[[nodiscard]] int getActiveCount() const;
|
||||
[[nodiscard]] auto getActiveCount() const -> int;
|
||||
|
||||
private:
|
||||
Graphics::VectorText text_; // Sistema de text vectorial
|
||||
@@ -49,7 +49,7 @@ class FloatingScoreManager {
|
||||
std::array<FloatingScore, MAX_PUNTUACIONS> pool_;
|
||||
|
||||
// Trobar primer slot inactiu
|
||||
FloatingScore* findFreeSlot();
|
||||
auto findFreeSlot() -> FloatingScore*;
|
||||
};
|
||||
|
||||
} // namespace Effects
|
||||
|
||||
Reference in New Issue
Block a user