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
+8 -8
View File
@@ -12,12 +12,12 @@ namespace Graphics {
Shape::Shape(const std::string& filepath)
: center_({.x = 0.0F, .y = 0.0F}),
escala_defecte_(1.0F),
nom_("unnamed") {
load(filepath);
}
bool Shape::load(const std::string& filepath) {
auto Shape::load(const std::string& filepath) -> bool {
// Llegir file
std::ifstream file(filepath);
if (!file.is_open()) {
@@ -35,7 +35,7 @@ bool Shape::load(const std::string& filepath) {
return parseFile(contingut);
}
bool Shape::parseFile(const std::string& contingut) {
auto Shape::parseFile(const std::string& contingut) -> bool {
std::istringstream iss(contingut);
std::string line;
@@ -89,7 +89,7 @@ bool Shape::parseFile(const std::string& contingut) {
}
// Helper: trim whitespace
std::string Shape::trim(const std::string& str) const {
auto Shape::trim(const std::string& str) const -> std::string {
const char* whitespace = " \t\n\r";
size_t start = str.find_first_not_of(whitespace);
if (start == std::string::npos) {
@@ -101,8 +101,8 @@ 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 {
auto Shape::starts_with(const std::string& str,
const std::string& prefix) const -> bool {
if (str.length() < prefix.length()) {
return false;
}
@@ -110,7 +110,7 @@ bool Shape::starts_with(const std::string& str,
}
// Helper: extract value after ':'
std::string Shape::extract_value(const std::string& line) const {
auto Shape::extract_value(const std::string& line) const -> std::string {
size_t colon = line.find(':');
if (colon == std::string::npos) {
return "";
@@ -134,7 +134,7 @@ void Shape::parse_center(const std::string& value) {
}
// Helper: parse points "x1,y1 x2,y2 x3,y3"
std::vector<Vec2> Shape::parse_points(const std::string& str) const {
auto Shape::parse_points(const std::string& str) const -> std::vector<Vec2> {
std::vector<Vec2> points;
std::istringstream iss(trim(str));
std::string pair;