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:
2026-05-20 10:59:56 +02:00
parent efbf2457a1
commit c45e524109
62 changed files with 268 additions and 280 deletions
+6 -6
View File
@@ -11,12 +11,12 @@
namespace Resource::Helper {
// Inicialitzar el sistema de recursos
bool initializeResourceSystem(const std::string& pack_file, bool fallback) {
auto initializeResourceSystem(const std::string& pack_file, bool fallback) -> bool {
return Loader::get().initialize(pack_file, fallback);
}
// Carregar un file
std::vector<uint8_t> loadFile(const std::string& filepath) {
auto loadFile(const std::string& filepath) -> std::vector<uint8_t> {
// Normalitzar la ruta
std::string normalized = normalizePath(filepath);
@@ -25,14 +25,14 @@ std::vector<uint8_t> loadFile(const std::string& filepath) {
}
// Comprovar si existeix un file
bool fileExists(const std::string& filepath) {
auto fileExists(const std::string& filepath) -> bool {
std::string normalized = normalizePath(filepath);
return Loader::get().resourceExists(normalized);
}
// Obtenir ruta normalitzada per al paquet
// Elimina prefixos "data/", rutes absolutes, etc.
std::string getPackPath(const std::string& asset_path) {
auto getPackPath(const std::string& asset_path) -> std::string {
std::string path = asset_path;
// Eliminar rutes absolutes (detectar / o C:\ al principi)
@@ -69,12 +69,12 @@ std::string getPackPath(const std::string& asset_path) {
}
// Normalitzar ruta (alias de getPackPath)
std::string normalizePath(const std::string& path) {
auto normalizePath(const std::string& path) -> std::string {
return getPackPath(path);
}
// Comprovar si hay paquet carregat
bool isPackLoaded() {
auto isPackLoaded() -> bool {
return Loader::get().isPackLoaded();
}
+6 -6
View File
@@ -11,17 +11,17 @@
namespace Resource::Helper {
// Inicialización del sistema
bool initializeResourceSystem(const std::string& pack_file, bool fallback);
auto initializeResourceSystem(const std::string& pack_file, bool fallback) -> bool;
// Càrrega de archivos
std::vector<uint8_t> loadFile(const std::string& filepath);
bool fileExists(const std::string& filepath);
auto loadFile(const std::string& filepath) -> std::vector<uint8_t>;
auto fileExists(const std::string& filepath) -> bool;
// Normalització de rutes
std::string getPackPath(const std::string& asset_path);
std::string normalizePath(const std::string& path);
auto getPackPath(const std::string& asset_path) -> std::string;
auto normalizePath(const std::string& path) -> std::string;
// Estat
bool isPackLoaded();
auto isPackLoaded() -> bool;
} // namespace Resource::Helper
+7 -7
View File
@@ -10,13 +10,13 @@
namespace Resource {
// Singleton
Loader& Loader::get() {
auto Loader::get() -> Loader& {
static Loader instance;
return instance;
}
// Inicialitzar el sistema de recursos
bool Loader::initialize(const std::string& pack_file, bool enable_fallback) {
auto Loader::initialize(const std::string& pack_file, bool enable_fallback) -> bool {
fallback_enabled_ = enable_fallback;
// Intentar load el paquet
@@ -39,7 +39,7 @@ bool Loader::initialize(const std::string& pack_file, bool enable_fallback) {
}
// Carregar un recurs
std::vector<uint8_t> Loader::loadResource(const std::string& filename) {
auto Loader::loadResource(const std::string& filename) -> std::vector<uint8_t> {
// Intentar load del paquet primer
if (pack_) {
if (pack_->hasResource(filename)) {
@@ -68,7 +68,7 @@ std::vector<uint8_t> Loader::loadResource(const std::string& filename) {
}
// Comprovar si existeix un recurs
bool Loader::resourceExists(const std::string& filename) {
auto Loader::resourceExists(const std::string& filename) -> bool {
// Comprovar al paquet
if (pack_ && pack_->hasResource(filename)) {
return true;
@@ -84,7 +84,7 @@ bool Loader::resourceExists(const std::string& filename) {
}
// Validar el paquet
bool Loader::validatePack() {
auto Loader::validatePack() -> bool {
if (!pack_) {
std::cerr << "[ResourceLoader] Advertència: no hay paquet carregat per validar\n";
return false;
@@ -94,7 +94,7 @@ bool Loader::validatePack() {
}
// Comprovar si hay paquet carregat
bool Loader::isPackLoaded() const {
auto Loader::isPackLoaded() const -> bool {
return pack_ != nullptr;
}
@@ -110,7 +110,7 @@ auto Loader::getBasePath() const -> const std::string& {
}
// Carregar des del sistema de archivos (fallback)
std::vector<uint8_t> Loader::loadFromFilesystem(const std::string& filename) {
auto Loader::loadFromFilesystem(const std::string& filename) -> std::vector<uint8_t> {
// The filename is already normalized (e.g., "shapes/logo/letra_j.shp")
// We need to prepend base_path + "data/"
std::string fullpath;
+8 -8
View File
@@ -16,18 +16,18 @@ namespace Resource {
class Loader {
public:
// Singleton
static Loader& get();
static auto get() -> Loader&;
// Inicialización
bool initialize(const std::string& pack_file, bool enable_fallback);
auto initialize(const std::string& pack_file, bool enable_fallback) -> bool;
// Càrrega de recursos
std::vector<uint8_t> loadResource(const std::string& filename);
bool resourceExists(const std::string& filename);
auto loadResource(const std::string& filename) -> std::vector<uint8_t>;
auto resourceExists(const std::string& filename) -> bool;
// Validació
bool validatePack();
[[nodiscard]] bool isPackLoaded() const;
auto validatePack() -> bool;
[[nodiscard]] auto isPackLoaded() const -> bool;
// Estat
void setBasePath(const std::string& path);
@@ -35,7 +35,7 @@ class Loader {
// No es pot copiar ni moure
Loader(const Loader&) = delete;
Loader& operator=(const Loader&) = delete;
auto operator=(const Loader&) -> Loader& = delete;
private:
Loader() = default;
@@ -47,7 +47,7 @@ class Loader {
std::string base_path_;
// Funciones auxiliars
std::vector<uint8_t> loadFromFilesystem(const std::string& filename);
auto loadFromFilesystem(const std::string& filename) -> std::vector<uint8_t>;
};
} // namespace Resource
+11 -11
View File
@@ -11,7 +11,7 @@
namespace Resource {
// Calcular checksum CRC32 simplificat
uint32_t Pack::calculateChecksum(const std::vector<uint8_t>& data) const {
auto Pack::calculateChecksum(const std::vector<uint8_t>& data) const -> uint32_t {
uint32_t checksum = 0x12345678;
for (unsigned char byte : data) {
checksum = ((checksum << 5) + checksum) + byte;
@@ -35,7 +35,7 @@ void Pack::decryptData(std::vector<uint8_t>& data, const std::string& key) {
}
// Llegir file complet a memòria
std::vector<uint8_t> Pack::readFile(const std::string& filepath) {
auto Pack::readFile(const std::string& filepath) -> std::vector<uint8_t> {
std::ifstream file(filepath, std::ios::binary | std::ios::ate);
if (!file) {
std::cerr << "[ResourcePack] Error: no es pot obrir " << filepath << '\n';
@@ -55,7 +55,7 @@ std::vector<uint8_t> Pack::readFile(const std::string& filepath) {
}
// Añadir un file individual al paquet
bool Pack::addFile(const std::string& filepath, const std::string& pack_name) {
auto Pack::addFile(const std::string& filepath, const std::string& pack_name) -> bool {
auto file_data = readFile(filepath);
if (file_data.empty()) {
return false;
@@ -78,8 +78,8 @@ bool Pack::addFile(const std::string& filepath, const std::string& pack_name) {
}
// Añadir todos los archivos de un directori recursivament
bool Pack::addDirectory(const std::string& dir_path,
const std::string& base_path) {
auto Pack::addDirectory(const std::string& dir_path,
const std::string& base_path) -> bool {
namespace fs = std::filesystem;
if (!fs::exists(dir_path) || !fs::is_directory(dir_path)) {
@@ -117,7 +117,7 @@ bool Pack::addDirectory(const std::string& dir_path,
}
// Guardar paquet a disc
bool Pack::savePack(const std::string& pack_file) {
auto Pack::savePack(const std::string& pack_file) -> bool {
std::ofstream file(pack_file, std::ios::binary);
if (!file) {
std::cerr << "[ResourcePack] Error: no es pot crear " << pack_file << '\n';
@@ -161,7 +161,7 @@ bool Pack::savePack(const std::string& pack_file) {
}
// Carregar paquet desde disc
bool Pack::loadPack(const std::string& pack_file) {
auto Pack::loadPack(const std::string& pack_file) -> bool {
std::ifstream file(pack_file, std::ios::binary);
if (!file) {
std::cerr << "[ResourcePack] Error: no es pot obrir " << pack_file << '\n';
@@ -226,7 +226,7 @@ bool Pack::loadPack(const std::string& pack_file) {
}
// Obtenir un recurs del paquet
std::vector<uint8_t> Pack::getResource(const std::string& filename) {
auto Pack::getResource(const std::string& filename) -> std::vector<uint8_t> {
auto it = resources_.find(filename);
if (it == resources_.end()) {
std::cerr << "[ResourcePack] Error: recurs no trobat: " << filename << '\n';
@@ -257,12 +257,12 @@ std::vector<uint8_t> Pack::getResource(const std::string& filename) {
}
// Comprovar si existeix un recurs
bool Pack::hasResource(const std::string& filename) const {
auto Pack::hasResource(const std::string& filename) const -> bool {
return resources_.contains(filename);
}
// Obtenir list de todos los recursos
std::vector<std::string> Pack::getResourceList() const {
auto Pack::getResourceList() const -> std::vector<std::string> {
std::vector<std::string> list;
list.reserve(resources_.size());
@@ -275,7 +275,7 @@ std::vector<std::string> Pack::getResourceList() const {
}
// Validar integritat del paquet
bool Pack::validatePack() const {
auto Pack::validatePack() const -> bool {
bool valid = true;
for (const auto& [name, entry] : resources_) {
+10 -10
View File
@@ -32,20 +32,20 @@ class Pack {
~Pack() = default;
// Añadir archivos al paquet
bool addFile(const std::string& filepath, const std::string& pack_name);
bool addDirectory(const std::string& dir_path, const std::string& base_path = "");
auto addFile(const std::string& filepath, const std::string& pack_name) -> bool;
auto addDirectory(const std::string& dir_path, const std::string& base_path = "") -> bool;
// Guardar i load paquets
bool savePack(const std::string& pack_file);
bool loadPack(const std::string& pack_file);
auto savePack(const std::string& pack_file) -> bool;
auto loadPack(const std::string& pack_file) -> bool;
// Accés a recursos
std::vector<uint8_t> getResource(const std::string& filename);
[[nodiscard]] bool hasResource(const std::string& filename) const;
[[nodiscard]] std::vector<std::string> getResourceList() const;
auto getResource(const std::string& filename) -> std::vector<uint8_t>;
[[nodiscard]] auto hasResource(const std::string& filename) const -> bool;
[[nodiscard]] auto getResourceList() const -> std::vector<std::string>;
// Validació
[[nodiscard]] bool validatePack() const;
[[nodiscard]] auto validatePack() const -> bool;
private:
// Constants
@@ -58,8 +58,8 @@ class Pack {
std::vector<uint8_t> data_;
// Funciones auxiliars
std::vector<uint8_t> readFile(const std::string& filepath);
[[nodiscard]] uint32_t calculateChecksum(const std::vector<uint8_t>& data) const;
auto readFile(const std::string& filepath) -> std::vector<uint8_t>;
[[nodiscard]] auto calculateChecksum(const std::vector<uint8_t>& data) const -> uint32_t;
void encryptData(std::vector<uint8_t>& data, const std::string& key);
void decryptData(std::vector<uint8_t>& data, const std::string& key);
};