Skip to content

Commit 5952e37

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

File tree

10 files changed

+28
-25
lines changed

10 files changed

+28
-25
lines changed

src/helper/nfd.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ namespace {
5656
auto* extensions = new nfdu8char_t[extension_list_size]; // NOLINT(cppcoreguidelines-owning-memory)
5757
std::memcpy(extensions, extension_list.c_str(), extension_list_size * sizeof(nfdu8char_t));
5858

59-
filter_item.get()[i] = { name, extensions };
59+
filter_item.get()[i] = { .name = name, .spec = extensions };
6060
}
6161
}
6262

@@ -68,7 +68,7 @@ namespace {
6868
} // namespace
6969

7070

71-
helper::expected<std::filesystem::path, std::string> helper::openFileDialog(
71+
helper::expected<std::filesystem::path, std::string> helper::open_file_dialog(
7272
const std::vector<AllowedFile>& allowed_files,
7373
std::optional<std::filesystem::path> default_path
7474
) {
@@ -108,7 +108,7 @@ helper::expected<std::filesystem::path, std::string> helper::openFileDialog(
108108
}
109109

110110

111-
[[nodiscard]] helper::expected<std::vector<std::filesystem::path>, std::string> helper::openMultipleFilesDialog(
111+
[[nodiscard]] helper::expected<std::vector<std::filesystem::path>, std::string> helper::open_multiple_files_dialog(
112112
const std::vector<AllowedFile>& allowed_files,
113113
std::optional<std::filesystem::path> default_path
114114
) {
@@ -160,7 +160,7 @@ helper::expected<std::filesystem::path, std::string> helper::openFileDialog(
160160
return helper::unexpected<std::string>{ "Error: " + std::string{ NFD::GetError() } };
161161
}
162162

163-
[[nodiscard]] helper::expected<std::filesystem::path, std::string> helper::openFolderDialog(
163+
[[nodiscard]] helper::expected<std::filesystem::path, std::string> helper::open_folder_dialog(
164164
std::optional<std::filesystem::path> default_path
165165
) {
166166

src/helper/nfd_include.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ namespace helper {
2727

2828

2929
//NOTE: this API is blocking and can't be asynchronous, due to os (linux, windows, macos) restrictions, it HAS to be launched in the same thread NFD_Init() was launched /the main thread)
30-
[[nodiscard]] helper::expected<std::filesystem::path, std::string> openFileDialog(
30+
[[nodiscard]] helper::expected<std::filesystem::path, std::string> open_file_dialog(
3131
const std::vector<AllowedFile>& allowed_files = {},
3232
std::optional<std::filesystem::path> default_path = std::nullopt
3333
);
3434

35-
[[nodiscard]] helper::expected<std::vector<std::filesystem::path>, std::string> openMultipleFilesDialog(
35+
[[nodiscard]] helper::expected<std::vector<std::filesystem::path>, std::string> open_multiple_files_dialog(
3636
const std::vector<AllowedFile>& allowed_files = {},
3737
std::optional<std::filesystem::path> default_path = std::nullopt
3838
);
3939

40-
[[nodiscard]] helper::expected<std::filesystem::path, std::string> openFolderDialog(
40+
[[nodiscard]] helper::expected<std::filesystem::path, std::string> open_folder_dialog(
4141
std::optional<std::filesystem::path> default_path = std::nullopt
4242
);
4343

src/libs/core/helper/color.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ namespace {
119119
}
120120

121121
// use custom fmod, that always result in a positive value
122-
const FloatType h = h_temp * static_cast<FloatType>(60.0); //degrees
122+
const FloatType hue = h_temp * static_cast<FloatType>(60.0); //degrees
123123

124-
const FloatType s = max == static_cast<FloatType>(0.0) ? static_cast<FloatType>(0.0) : delta / max;
124+
const FloatType saturation = max == static_cast<FloatType>(0.0) ? static_cast<FloatType>(0.0) : delta / max;
125125

126126
//v = max
127127

128-
return HSVColor{ static_cast<double>(h), static_cast<double>(s), static_cast<double>(max), a };
128+
return HSVColor{ static_cast<double>(hue), static_cast<double>(saturation), static_cast<double>(max), a };
129129
}
130130

131131
//Note: this output formats are all deserializable by the from_string method!

src/manager/music_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ std::optional<double> MusicManager::change_volume(const std::int8_t steps) {
340340
return 1.0F;
341341
}
342342

343-
new_volume = current_volume.value() + MusicManager::step_width * static_cast<double>(steps);
343+
new_volume = current_volume.value() + (MusicManager::step_width * static_cast<double>(steps));
344344
}
345345

346346
if (new_volume >= 1.0F) {

src/scenes/loading_screen/loading_screen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void scenes::LoadingScreen::update() {
8484

8585
const auto offset = std::numbers::pi_v<double> * 2.0 * static_cast<double>(length - i - 1) / length_d;
8686

87-
scale = std::min(amplitude * std::sin(time * speed + offset) + scale_offset, 1.0);
87+
scale = std::min((amplitude * std::sin((time * speed) + offset)) + scale_offset, 1.0);
8888
}
8989
//
9090
}
@@ -122,6 +122,6 @@ void scenes::LoadingScreen::render(const ServiceProvider& service_provider) cons
122122
[[nodiscard]] shapes::UPoint scenes::LoadingScreen::to_screen_coords(const Mino::GridPoint& point, u32 tile_size)
123123
const {
124124
const auto start_edge = m_start_offset + point.cast<u32>() * m_tile_size;
125-
const auto inner_offset = m_tile_size - tile_size / 2;
125+
const auto inner_offset = m_tile_size - (tile_size / 2);
126126
return start_edge + shapes::UPoint{ inner_offset, inner_offset };
127127
}

src/scenes/recording_selector/recording_chooser.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ custom_ui::RecordingFileChooser::RecordingFileChooser(
3131
[service_provider, this](const ui::TextButton&) -> bool {
3232
this->prepare_dialog(service_provider);
3333

34-
const auto result = helper::openMultipleFilesDialog({
35-
{ "OOPetris Recording", { constants::recording::extension } }
34+
const auto result = helper::open_multiple_files_dialog({
35+
{ .name = "OOPetris Recording", .extension_list = { constants::recording::extension } }
3636
});
3737

3838
if (result.has_value()) {
@@ -58,7 +58,7 @@ custom_ui::RecordingFileChooser::RecordingFileChooser(
5858
[this, service_provider](const ui::TextButton&) -> bool {
5959
this->prepare_dialog(service_provider);
6060

61-
const auto result = helper::openFolderDialog();
61+
const auto result = helper::open_folder_dialog();
6262

6363
if (result.has_value()) {
6464

src/scenes/recording_selector/recording_selector.cpp

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

2626
namespace scenes {
2727

28-
using namespace details::recording::selector;
28+
using namespace details::recording::selector; //NOLINT(google-build-using-namespace)
2929

3030
RecordingSelector::RecordingSelector(ServiceProvider* service_provider, const ui::Layout& layout)
3131
: Scene{ service_provider, layout },

src/scenes/settings_menu/settings_menu.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
namespace scenes {
1919

20-
using namespace details::settings::menu;
20+
using namespace details::settings::menu; // NOLINT(google-build-using-namespace)
2121

2222
SettingsMenu::SettingsMenu(ServiceProvider* service_provider, const ui::Layout& layout)
2323
: SettingsMenu{ service_provider, layout, std::nullopt } { }
@@ -133,7 +133,7 @@ namespace scenes {
133133

134134
scroll_layout->add<custom_ui::ColorSettingRow>(
135135
ui::RelativeItemSize{ scroll_layout->layout(), 0.2 }, service_provider,
136-
//TODO use real settings name
136+
//TODO(Totto): use real settings name
137137
fmt::format("Color {}", color_index), color,
138138
[this, color_index](const Color& updated_color) { this->m_colors.at(color_index) = updated_color; },
139139
focus_helper.focus_id()

tests/core/color.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,27 @@ namespace {
2626

2727
} // namespace
2828

29+
2930
// helper thought just for the tests
30-
[[nodiscard]] constexpr bool operator==(const HSVColor& value1, const HSVColor& value2) {
31+
[[nodiscard]] constexpr bool
32+
operator==(const HSVColor& value1, const HSVColor& value2) { //NOLINT(misc-use-internal-linkage)
3133
return value1.to_rgb_color() == value2.to_rgb_color();
3234
}
3335

3436

3537
// make colors printable
36-
void PrintTo(const Color& color, std::ostream* os) {
38+
void PrintTo(const Color& color, std::ostream* os) { //NOLINT(misc-use-internal-linkage)
3739
*os << color.to_string();
3840
}
3941

40-
void PrintTo(const HSVColor& color, std::ostream* os) {
42+
void PrintTo(const HSVColor& color, std::ostream* os) { //NOLINT(misc-use-internal-linkage)
4143
*os << color.to_string();
4244
}
4345

46+
4447
namespace color {
4548

46-
void PrintTo(const SerializeMode& value, std::ostream* os) {
49+
void PrintTo(const SerializeMode& value, std::ostream* os) { //NOLINT(misc-use-internal-linkage)
4750
*os << magic_enum::enum_name(value);
4851
}
4952

tests/graphics/sdl_key.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
namespace sdl {
1414

1515
// make keys printable
16-
void PrintTo(const Key& key, std::ostream* os) {
16+
void PrintTo(const Key& key, std::ostream* os) { //NOLINT(misc-use-internal-linkage)
1717
*os << key.to_string();
1818
}
1919

2020

21-
std::ostream& operator<<(std::ostream& os, const Key& value) {
21+
std::ostream& operator<<(std::ostream& os, const Key& value) { //NOLINT(misc-use-internal-linkage)
2222
os << value.to_string();
2323
return os;
2424
}

0 commit comments

Comments
 (0)