style: aplicar todos los checks readability-* (225 fixes)

Cambios aplicados:
- readability-braces-around-statements (añadir llaves en ifs/fors)
- readability-implicit-bool-conversion (puntero → bool explícito)
- readability-container-size-empty (.empty() en lugar de .size()==0)
- readability-container-contains (.contains() C++20)
- readability-make-member-function-const (métodos const)
- readability-else-after-return (5 casos adicionales)
- Añadido #include <cmath> en defaults.hpp

Checks excluidos (justificados):
- identifier-naming: Cascada de 300+ cambios
- identifier-length: Nombres cortos son OK en este proyecto
- magic-numbers: Demasiados falsos positivos
- convert-member-functions-to-static: Rompe encapsulación
- use-anyofallof: C++20 ranges no universal
- function-cognitive-complexity: Complejidad aceptable
- clang-analyzer-security.insecureAPI.rand: rand() suficiente para juegos
This commit is contained in:
2025-12-18 19:51:43 +01:00
parent 2088ccdcc6
commit fdfb84170f
28 changed files with 258 additions and 167 deletions

View File

@@ -18,8 +18,9 @@ GestorPuntuacioFlotant::GestorPuntuacioFlotant(SDL_Renderer* renderer)
void GestorPuntuacioFlotant::crear(int punts, const Punt& posicio) {
// 1. Trobar slot lliure
PuntuacioFlotant* pf = trobar_slot_lliure();
if (!pf)
if (pf == nullptr) {
return; // Pool ple (improbable)
}
// 2. Inicialitzar puntuació flotant
pf->text = std::to_string(punts);
@@ -34,8 +35,9 @@ void GestorPuntuacioFlotant::crear(int punts, const Punt& posicio) {
void GestorPuntuacioFlotant::actualitzar(float delta_time) {
for (auto& pf : pool_) {
if (!pf.actiu)
if (!pf.actiu) {
continue;
}
// 1. Actualitzar posició (deriva cap amunt)
pf.posicio.x += pf.velocitat.x * delta_time;
@@ -57,8 +59,9 @@ void GestorPuntuacioFlotant::actualitzar(float delta_time) {
void GestorPuntuacioFlotant::dibuixar() {
for (const auto& pf : pool_) {
if (!pf.actiu)
if (!pf.actiu) {
continue;
}
// Renderitzar centrat amb brightness (fade)
constexpr float escala = Defaults::FloatingScore::SCALE;
@@ -77,16 +80,18 @@ void GestorPuntuacioFlotant::reiniciar() {
int GestorPuntuacioFlotant::get_num_actius() const {
int count = 0;
for (const auto& pf : pool_) {
if (pf.actiu)
if (pf.actiu) {
count++;
}
}
return count;
}
PuntuacioFlotant* GestorPuntuacioFlotant::trobar_slot_lliure() {
for (auto& pf : pool_) {
if (!pf.actiu)
if (!pf.actiu) {
return &pf;
}
}
return nullptr; // Pool ple
}