clang-tidy modernize
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
#include "enter_name.h"
|
||||
|
||||
#include <stddef.h> // Para size_t
|
||||
#include <stdlib.h> // Para rand
|
||||
|
||||
#include <cstddef> // Para size_t
|
||||
#include <cstdlib> // Para rand
|
||||
#include <string_view> // Para basic_string_view, string_view
|
||||
|
||||
#include "utils.h" // Para trim
|
||||
@@ -133,7 +132,7 @@ void EnterName::initCharacterIndex(const std::string &name) {
|
||||
}
|
||||
|
||||
// Encuentra el indice de un caracter en "character_list_"
|
||||
int EnterName::findIndex(char character) const {
|
||||
auto EnterName::findIndex(char character) const -> int {
|
||||
for (size_t i = 0; i < character_list_.size(); ++i) {
|
||||
if (character == character_list_.at(i)) {
|
||||
return i;
|
||||
@@ -143,13 +142,13 @@ int EnterName::findIndex(char character) const {
|
||||
}
|
||||
|
||||
// Devuelve un nombre al azar
|
||||
std::string EnterName::getRandomName() {
|
||||
auto EnterName::getRandomName() -> std::string {
|
||||
static constexpr std::array<std::string_view, 8> NAMES = {
|
||||
"BAL1", "TABE", "DOC", "MON", "SAM1", "JORDI", "JDES", "PEPE"};
|
||||
return std::string(NAMES[rand() % NAMES.size()]);
|
||||
}
|
||||
// Obtiene el nombre final introducido
|
||||
std::string EnterName::getFinalName() {
|
||||
auto EnterName::getFinalName() -> std::string {
|
||||
auto name = trim(name_.substr(0, position_));
|
||||
if (name.empty()) {
|
||||
name = getRandomName();
|
||||
|
||||
Reference in New Issue
Block a user