clang-tidy readability-function-cognitive-complexity

This commit is contained in:
2025-07-20 15:24:47 +02:00
parent ca99f7be34
commit cb4e4b450d
20 changed files with 315 additions and 434 deletions

View File

@@ -108,55 +108,67 @@ void Title::checkEvents() {
SDL_Event event;
while (SDL_PollEvent(&event)) {
#ifdef DEBUG
if (event.type == SDL_EVENT_KEY_DOWN && event.key.repeat == 1) {
if (event.type == SDL_EVENT_KEY_DOWN && static_cast<int>(event.key.repeat) == 1) {
static Color color_ = param.title.bg_color;
switch (event.key.key) {
case SDLK_A:
if (color_.r < 255)
if (color_.r < 255) {
++color_.r;
}
break;
case SDLK_Z:
if (color_.r > 0)
if (color_.r > 0) {
--color_.r;
}
break;
case SDLK_S:
if (color_.g < 255)
if (color_.g < 255) {
++color_.g;
}
break;
case SDLK_X:
if (color_.g > 0)
if (color_.g > 0) {
--color_.g;
}
break;
case SDLK_D:
if (color_.b < 255)
if (color_.b < 255) {
++color_.b;
}
break;
case SDLK_C:
if (color_.b > 0)
if (color_.b > 0) {
--color_.b;
}
break;
case SDLK_F:
if (color_.r < 255)
if (color_.r < 255) {
++color_.r;
if (color_.g < 255)
}
if (color_.g < 255) {
++color_.g;
if (color_.b < 255)
}
if (color_.b < 255) {
++color_.b;
}
break;
case SDLK_V:
if (color_.r > 0)
if (color_.r > 0) {
--color_.r;
if (color_.g > 0)
}
if (color_.g > 0) {
--color_.g;
if (color_.b > 0)
}
if (color_.b > 0) {
--color_.b;
}
break;
default:
@@ -171,7 +183,7 @@ void Title::checkEvents() {
<< std::endl;
}
#endif
if (event.type == SDL_EVENT_KEY_DOWN && event.key.repeat == 0) {
if (event.type == SDL_EVENT_KEY_DOWN && static_cast<int>(event.key.repeat) == 0) {
switch (event.key.key) {
case SDLK_1: // Redefine los botones del mando #0
define_buttons_->enable(0);
@@ -211,8 +223,9 @@ void Title::checkEvents() {
// Comprueba las entradas
void Title::checkInput() {
// Comprueba las entradas solo si no se estan definiendo los botones
if (define_buttons_->isEnabled())
if (define_buttons_->isEnabled()) {
return;
}
Input::get()->update();
@@ -263,8 +276,9 @@ void Title::resetCounter() { counter_ = 0; }
// Intercambia la asignación de mandos a los jugadores
void Title::swapControllers() {
if (Input::get()->getNumControllers() == 0)
if (Input::get()->getNumControllers() == 0) {
return;
}
Options::swapControllers();
showControllers();
@@ -443,8 +457,9 @@ void Title::renderCopyright() {
// Cambia el estado
void Title::setState(TitleState state) {
if (state_ == state)
if (state_ == state) {
return;
}
state_ = state;
switch (state_) {