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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user