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:
@@ -44,8 +44,9 @@ bool Shape::parsejar_fitxer(const std::string& contingut) {
|
||||
line = trim(line);
|
||||
|
||||
// Skip comments and blanks
|
||||
if (line.empty() || line[0] == '#')
|
||||
if (line.empty() || line[0] == '#') {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Parse command
|
||||
if (starts_with(line, "name:")) {
|
||||
@@ -91,8 +92,9 @@ bool Shape::parsejar_fitxer(const std::string& contingut) {
|
||||
std::string Shape::trim(const std::string& str) const {
|
||||
const char* whitespace = " \t\n\r";
|
||||
size_t start = str.find_first_not_of(whitespace);
|
||||
if (start == std::string::npos)
|
||||
if (start == std::string::npos) {
|
||||
return "";
|
||||
}
|
||||
|
||||
size_t end = str.find_last_not_of(whitespace);
|
||||
return str.substr(start, end - start + 1);
|
||||
@@ -101,16 +103,18 @@ std::string Shape::trim(const std::string& str) const {
|
||||
// Helper: starts_with
|
||||
bool Shape::starts_with(const std::string& str,
|
||||
const std::string& prefix) const {
|
||||
if (str.length() < prefix.length())
|
||||
if (str.length() < prefix.length()) {
|
||||
return false;
|
||||
}
|
||||
return str.compare(0, prefix.length(), prefix) == 0;
|
||||
}
|
||||
|
||||
// Helper: extract value after ':'
|
||||
std::string Shape::extract_value(const std::string& line) const {
|
||||
size_t colon = line.find(':');
|
||||
if (colon == std::string::npos)
|
||||
if (colon == std::string::npos) {
|
||||
return "";
|
||||
}
|
||||
return line.substr(colon + 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ Starfield::Starfield(SDL_Renderer* renderer,
|
||||
}
|
||||
|
||||
// Inicialitzar una estrella (nova o regenerada)
|
||||
void Starfield::inicialitzar_estrella(Estrella& estrella) {
|
||||
void Starfield::inicialitzar_estrella(Estrella& estrella) const {
|
||||
// Angle aleatori des del punt de fuga cap a fora
|
||||
estrella.angle = (static_cast<float>(rand()) / RAND_MAX) * 2.0F * Defaults::Math::PI;
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class Starfield {
|
||||
};
|
||||
|
||||
// Inicialitzar una estrella (nova o regenerada)
|
||||
void inicialitzar_estrella(Estrella& estrella);
|
||||
void inicialitzar_estrella(Estrella& estrella) const;
|
||||
|
||||
// Verificar si una estrella està fora de l'àrea
|
||||
bool fora_area(const Estrella& estrella) const;
|
||||
|
||||
@@ -178,11 +178,11 @@ std::string VectorText::get_shape_filename(char c) const {
|
||||
}
|
||||
|
||||
bool VectorText::is_supported(char c) const {
|
||||
return chars_.find(c) != chars_.end();
|
||||
return chars_.contains(c);
|
||||
}
|
||||
|
||||
void VectorText::render(const std::string& text, const Punt& posicio, float escala, float spacing, float brightness) {
|
||||
if (!renderer_) {
|
||||
if (renderer_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user