Skip to content

Commit f36fd59

Browse files
committed
fix: fix many clang tidy errors (8/x)
this is part 8 of 143 errors in the whole codebase, it is split into multiple commits, so that each patch is not to big
1 parent 21a2ea3 commit f36fd59

File tree

7 files changed

+28
-27
lines changed

7 files changed

+28
-27
lines changed

src/libs/core/helper/expected.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ namespace helper {
1212

1313
#ifdef _USE_TL_EXPECTED
1414
template<typename S, typename T>
15-
using expected = tl::expected<S, T>;
15+
using expected = tl::expected<S, T>; //NOLINT(readability-identifier-naming)
1616

1717
template<typename T>
18-
using unexpected = tl::unexpected<T>;
18+
using unexpected = tl::unexpected<T>; //NOLINT(readability-identifier-naming)
1919

2020
#else
2121
template<typename S, typename T>
22-
using expected = std::expected<S, T>;
22+
using expected = std::expected<S, T>; //NOLINT(readability-identifier-naming)
2323

2424
template<typename T>
25-
using unexpected = std::unexpected<T>;
25+
using unexpected = std::unexpected<T>; //NOLINT(readability-identifier-naming)
2626

2727
#endif
2828

src/libs/core/helper/static_string.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ struct StaticString {
1717
constexpr StaticString() : m_data{} { }
1818

1919
public:
20-
constexpr StaticString(const char (&chars // NOLINT(modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays)
20+
constexpr explicit StaticString(const char( // NOLINT(modernize-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays)
21+
&chars
2122
)[DataSize]) {
2223
std::copy(chars, chars + DataSize, begin());
2324
}

src/libs/core/helper/types.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
#include <cstdint>
44
#include <cstdlib>
55

6-
using usize = std::size_t;
7-
using u8 = std::uint8_t;
8-
using u16 = std::uint16_t;
9-
using u32 = std::uint32_t;
10-
using u64 = std::uint64_t;
11-
using i8 = std::int8_t;
12-
using i16 = std::int16_t;
13-
using i32 = std::int32_t;
14-
using i64 = std::int64_t;
6+
using usize = std::size_t; //NOLINT(readability-identifier-naming)
7+
using u8 = std::uint8_t; //NOLINT(readability-identifier-naming)
8+
using u16 = std::uint16_t; //NOLINT(readability-identifier-naming)
9+
using u32 = std::uint32_t; //NOLINT(readability-identifier-naming)
10+
using u64 = std::uint64_t; //NOLINT(readability-identifier-naming)
11+
using i8 = std::int8_t; //NOLINT(readability-identifier-naming)
12+
using i16 = std::int16_t; //NOLINT(readability-identifier-naming)
13+
using i32 = std::int32_t; //NOLINT(readability-identifier-naming)
14+
using i64 = std::int64_t; //NOLINT(readability-identifier-naming)
1515

1616
using SimulationStep = u64;

src/manager/event_dispatcher.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ struct EventDispatcher final {
8585
}
8686

8787
if (rect.has_value()) {
88-
SDL_Rect sdl_rect = rect.value().to_sdl_rect();
88+
const SDL_Rect sdl_rect = rect.value().to_sdl_rect();
8989
SDL_SetTextInputRect(&sdl_rect);
9090
}
9191

src/manager/font.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99

1010
struct FontLoadingError final : public std::exception {
1111
private:
12-
std::string message;
12+
std::string m_message;
1313

1414
public:
15-
OOPETRIS_GRAPHICS_EXPORTED explicit FontLoadingError(std::string message) : message{ std::move(message) } { }
15+
OOPETRIS_GRAPHICS_EXPORTED explicit FontLoadingError(std::string message) : m_message{ std::move(message) } { }
1616

1717
[[nodiscard]] const char* what() const noexcept override {
18-
return message.c_str();
18+
return m_message.c_str();
1919
}
2020
};
2121

src/manager/music_manager.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ MusicManager::MusicManager(ServiceProvider* service_provider, u8 channel_size)
2020
m_channel_size{ channel_size },
2121
m_chunk_map{ std::unordered_map<std::string, Mix_Chunk*>{} },
2222
m_volume{ service_provider->command_line_arguments().silent ? std::nullopt : std::optional{ 1.0F } } {
23-
if (s_instance != nullptr) {
23+
if (m_s_instance != nullptr) {
2424
spdlog::error(
2525
"it's not allowed to create more than one MusicManager instance: {} != {}",
26-
static_cast<void*>(s_instance), static_cast<void*>(this)
26+
static_cast<void*>(m_s_instance), static_cast<void*>(this)
2727
);
2828
return;
2929
}
@@ -65,7 +65,7 @@ MusicManager::MusicManager(ServiceProvider* service_provider, u8 channel_size)
6565
throw helper::InitializationError{ fmt::format("Failed to open an audio device: {}", SDL_GetError()) };
6666
}
6767

68-
s_instance = this;
68+
m_s_instance = this;
6969

7070
set_volume(m_volume, true);
7171
}
@@ -97,7 +97,7 @@ MusicManager::~MusicManager() noexcept {
9797
Mix_CloseAudio();
9898
Mix_Quit();
9999

100-
s_instance = nullptr;
100+
m_s_instance = nullptr;
101101
}
102102

103103
std::optional<std::string> MusicManager::load_and_play_music(const std::filesystem::path& location, const usize delay) {
@@ -159,11 +159,11 @@ std::optional<std::string> MusicManager::load_and_play_music(const std::filesyst
159159
m_delay = delay;
160160
Mix_HookMusicFinished([]() {
161161
// this can happen on e.g. android, where if we exit the application, we don't close the window, so its reused, but the music manager is destroyed, but the hook is called later xD
162-
/* if (s_instance == nullptr) {
162+
/* if (m_s_instance == nullptr) {
163163
return;
164164
} */
165165

166-
s_instance->hook_music_finished();
166+
m_s_instance->hook_music_finished();
167167
});
168168

169169
// this wasn't block, so we have to wait for the callback to be called
@@ -252,10 +252,10 @@ void MusicManager::hook_music_finished() {
252252
}
253253

254254
[[nodiscard]] bool MusicManager::validate_instance() {
255-
if (s_instance != this) {
255+
if (m_s_instance != this) {
256256
spdlog::error(
257257
"this MusicManager instance is not the instance that is used globally: {} != {}",
258-
static_cast<void*>(s_instance), static_cast<void*>(this)
258+
static_cast<void*>(m_s_instance), static_cast<void*>(this)
259259
);
260260
return false;
261261
}

src/manager/music_manager.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
struct MusicManager final {
2222
private:
23-
static inline MusicManager* s_instance{ nullptr }; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
23+
static inline MusicManager* m_s_instance{ nullptr }; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
2424
static const constexpr double step_width = 0.05F;
2525

2626
using VolumeChangeFunction = std::function<void(std::optional<double> volume)>;

0 commit comments

Comments
 (0)