clang-tidy

This commit is contained in:
2025-08-17 10:20:41 +02:00
parent b359a73d50
commit 8ddc5d94f1
73 changed files with 867 additions and 833 deletions

View File

@@ -8,8 +8,9 @@
#include <cmath> // Para pow, sin, M_PI, cos, sqrt
#include <compare> // Para operator<, __synth3way_t
#include <filesystem> // Para path
#include <stdexcept> // Para runtime_error
#include <string> // Para basic_string, allocator, string, operator==, operator+, char_traits
#include <ranges>
#include <stdexcept> // Para runtime_error
#include <string> // Para basic_string, allocator, string, operator==, operator+, char_traits
#include "lang.h" // Para getText
@@ -20,14 +21,14 @@ Overrides overrides = Overrides();
auto distanceSquared(int x1, int y1, int x2, int y2) -> double {
const int DELTA_X = x2 - x1;
const int DELTA_Y = y2 - y1;
return DELTA_X * DELTA_X + DELTA_Y * DELTA_Y;
return (DELTA_X * DELTA_X) + (DELTA_Y * DELTA_Y);
}
// Obtiene el punto de colisión entre dos circulos
auto getCollisionPoint(const Circle &a, const Circle &b) -> SDL_FPoint {
float dx = b.x - a.x;
float dy = b.y - a.y;
float dist = std::sqrt(dx * dx + dy * dy);
float dist = std::sqrt((dx * dx) + (dy * dy));
// Normaliza el vector
float nx = dx / dist;
@@ -117,7 +118,7 @@ auto boolToOnOff(bool value) -> std::string {
// Convierte una cadena a minusculas
auto toLower(const std::string &str) -> std::string {
std::string result = str;
std::transform(result.begin(), result.end(), result.begin(), [](unsigned char c) { return std::tolower(c); });
std::ranges::transform(result, result.begin(), [](unsigned char c) { return std::tolower(c); });
return result;
}
@@ -158,8 +159,8 @@ void drawCircle(SDL_Renderer *renderer, int32_t center_x, int32_t center_y, int3
// Quita los espacioes en un string
auto trim(const std::string &str) -> std::string {
auto start = std::find_if_not(str.begin(), str.end(), ::isspace);
auto end = std::find_if_not(str.rbegin(), str.rend(), ::isspace).base();
auto start = std::ranges::find_if_not(str, ::isspace);
auto end = std::ranges::find_if_not(std::ranges::reverse_view(str), ::isspace).base();
return (start < end ? std::string(start, end) : std::string());
}
@@ -175,7 +176,7 @@ auto easeInQuint(double time) -> double {
// Función de suavizado
auto easeInOutQuint(double time) -> double {
return time < 0.5 ? 16 * pow(time, 5) : 1 - pow(-2 * time + 2, 5) / 2;
return time < 0.5 ? 16 * pow(time, 5) : 1 - (pow((-2 * time) + 2, 5) / 2);
}
// Función de suavizado
@@ -185,7 +186,7 @@ auto easeInQuad(double time) -> double {
// Función de suavizado
auto easeOutQuad(double time) -> double {
return 1 - (1 - time) * (1 - time);
return 1 - ((1 - time) * (1 - time));
}
// Función de suavizado
@@ -195,7 +196,7 @@ auto easeInOutSine(double time) -> double {
// Función de suavizado
auto easeInOut(double time) -> double {
return time < 0.5 ? 2 * time * time : -1 + (4 - 2 * time) * time;
return time < 0.5 ? 2 * time * time : -1 + ((4 - 2 * time) * time);
}
// Función de suavizado (easeInOutExpo)
@@ -209,10 +210,10 @@ auto easeInOutExpo(double time) -> double {
}
if (time < 0.5) {
return pow(2, 20 * time - 10) / 2;
return pow(2, (20 * time) - 10) / 2;
}
return (2 - pow(2, -20 * time + 10)) / 2;
return (2 - pow(2, (-20 * time) + 10)) / 2;
}
// Función de suavizado (easeInElastic)
@@ -226,7 +227,7 @@ auto easeInElastic(double time) -> double {
}
const double C4 = (2 * M_PI) / 3;
return -pow(2, 10 * time - 10) * sin((time * 10 - 10.75) * C4);
return -pow(2, (10 * time) - 10) * sin((time * 10 - 10.75) * C4);
}
// Función de suavizado
@@ -236,14 +237,14 @@ auto easeOutBounce(double time) -> double {
}
if (time < 2 / 2.75) {
time -= 1.5 / 2.75;
return 7.5625 * time * time + 0.75;
return (7.5625 * time * time) + 0.75;
}
if (time < 2.5 / 2.75) {
time -= 2.25 / 2.75;
return 7.5625 * time * time + 0.9375;
return (7.5625 * time * time) + 0.9375;
}
time -= 2.625 / 2.75;
return 7.5625 * time * time + 0.984375;
return (7.5625 * time * time) + 0.984375;
}
// Función de suavizado (easeOutElastic)
@@ -257,7 +258,7 @@ auto easeOutElastic(double time) -> double {
}
const double C4 = (2 * M_PI) / 3; // Constante para controlar la elasticidad
return pow(2, -10 * time) * sin((time * 10 - 0.75) * C4) + 1;
return (pow(2, -10 * time) * sin((time * 10 - 0.75) * C4)) + 1;
}
// Ease Out Expo - Muy suave al final (más dramático)
@@ -274,7 +275,7 @@ auto easeInExpo(double time) -> double {
auto easeOutBack(double time) -> double {
const double C1 = 1.70158F;
const double C3 = C1 + 1.0F;
return 1.0F + C3 * pow(time - 1.0F, 3.0F) + C1 * pow(time - 1.0F, 2.0F);
return 1.0F + (C3 * pow(time - 1.0F, 3.0F)) + (C1 * pow(time - 1.0F, 2.0F));
}
// Ease Out Cubic - Desaceleración suave al final
@@ -289,7 +290,7 @@ auto easeInCubic(double time) -> double {
// Comprueba si una vector contiene una cadena
auto stringInVector(const std::vector<std::string> &vec, const std::string &str) -> bool {
return std::find(vec.begin(), vec.end(), str) != vec.end();
return std::ranges::find(vec, str) != vec.end();
}
// Imprime por pantalla una línea de texto de tamaño fijo rellena con puntos
@@ -389,7 +390,8 @@ auto truncateWithEllipsis(const std::string &input, size_t length) -> std::strin
return input;
}
if (length <= 3) {
return std::string(length, '.');
std::string result(length, '.');
return result;
}
return input.substr(0, length) + "...";
}