Skip to content

Commit 944b965

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

File tree

19 files changed

+127
-123
lines changed

19 files changed

+127
-123
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
tidy-checks: ''
5353
step-summary: true
5454
file-annotations: true
55-
ignore: subprojects|build|android|assets|recordings|docs|toolchains|platforms|wrapper|src/libs/core/hash-library|src/lobby/curl_client.*
55+
ignore: subprojects|build|android|assets|recordings|docs|toolchains|platforms|wrapper|src/libs/core/hash-library|tests|src/lobby/curl_client.*
5656

5757
- name: Fail CI run if linter checks failed
5858
if: steps.linter.outputs.checks-failed != 0

src/executables/game/application.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,11 @@ void Application::update() {
201201
},
202202
[this](const scenes::Scene::Switch& scene_switch) {
203203
spdlog::info(
204-
"switching to scene {}", magic_enum::enum_name(scene_switch.target_scene)
204+
"switching to scene {}", magic_enum::enum_name(scene_switch.m_target_scene)
205+
);
206+
auto scene = scenes::create_scene(
207+
*this, scene_switch.m_target_scene, scene_switch.m_layout
205208
);
206-
auto scene =
207-
scenes::create_scene(*this, scene_switch.target_scene, scene_switch.layout);
208209

209210
// only clear, after the construction was successful
210211
m_scene_stack.clear();

src/executables/game/application.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ struct Application final : public EventListener, public ServiceProvider {
4545
#endif
4646

4747
protected:
48-
EventDispatcher m_event_dispatcher; // NOLINT(misc-non-private-member-variables-in-classes)
48+
EventDispatcher
49+
m_event_dispatcher; //NOLINT(misc-non-private-member-variables-in-classes,cppcoreguidelines-non-private-member-variables-in-classes)
4950

5051
private:
5152
std::vector<std::unique_ptr<scenes::Scene>> m_scene_stack;

src/graphics/rect.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ namespace shapes {
1717
constexpr AbstractRect(Point top_left, Point bottom_right) // NOLINT(bugprone-easily-swappable-parameters)
1818
: top_left{ top_left },
1919
bottom_right{ bottom_right } { }
20-
constexpr AbstractRect(T x, T y, T width, T height)
21-
: top_left{ x, y },
22-
bottom_right{ x + width - 1, y + height - 1 } { }
20+
constexpr AbstractRect(T x_pos, T y_pos, T width, T height)
21+
: top_left{ x_pos, y_pos },
22+
bottom_right{ x_pos + width - 1, y_pos + height - 1 } { }
2323

2424
[[nodiscard]] constexpr T width() const {
2525
return static_cast<T>(bottom_right.x - top_left.x + 1);

src/graphics/renderer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ void Renderer::draw_self_computed_circle_impl(const shapes::IPoint& center, i32
100100
while (x_pos >= y_pos) {
101101
// Each of the following renders an octant of the circle
102102
SDL_RenderDrawPoint(
103-
m_renderer, center_x + x_pos,
104-
center_y - y_pos // NOLINT(clang-analyzer-core.UndefinedBinaryOperatorResult)
103+
m_renderer, center_x + x_pos, // NOLINT(clang-analyzer-core.UndefinedBinaryOperatorResult)
104+
center_y - y_pos
105105
);
106106
SDL_RenderDrawPoint(m_renderer, center_x + x_pos, center_y + y_pos);
107107
SDL_RenderDrawPoint(m_renderer, center_x - x_pos, center_y - y_pos);

src/graphics/renderer.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ struct Renderer final {
7373
}
7474

7575
template<typename S, typename T>
76-
void draw_texture(const Texture& texture, const shapes::AbstractRect<S>& from, const shapes::AbstractRect<T>& to)
76+
void draw_texture(const Texture& texture, const shapes::AbstractRect<S>& from, const shapes::AbstractRect<T>& dest)
7777
const {
78-
texture.render(m_renderer, from, to);
78+
texture.render(m_renderer, from, dest);
7979
}
8080

8181
OOPETRIS_GRAPHICS_EXPORTED [[nodiscard]] Texture load_image(const std::filesystem::path& image_path) const;

src/graphics/texture.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ struct Texture {
5656
}
5757

5858
template<typename T>
59-
void render(SDL_Renderer* renderer, const shapes::AbstractRect<T>& from, const shapes::URect& to) const {
59+
void render(SDL_Renderer* renderer, const shapes::AbstractRect<T>& from, const shapes::URect& dest) const {
6060
const SDL_Rect from_rect_sdl = from.to_sdl_rect();
61-
const SDL_Rect to_rect_sdl = to.to_sdl_rect();
61+
const SDL_Rect to_rect_sdl = dest.to_sdl_rect();
6262
SDL_RenderCopy(renderer, m_raw_texture, &from_rect_sdl, &to_rect_sdl);
6363
}
6464

src/scenes/recording_selector/recording_chooser.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ custom_ui::RecordingFileChooser::RecordingFileChooser(
3737

3838
if (result.has_value()) {
3939
for (const auto& path : result.value()) {
40-
this->currently_chosen_files.push_back(path);
40+
this->m_currently_chosen_files.push_back(path);
4141
}
4242
} else {
4343
spdlog::warn("error in dialog: {}", result.error());
@@ -66,7 +66,7 @@ custom_ui::RecordingFileChooser::RecordingFileChooser(
6666
for (const auto& file : std::filesystem::recursive_directory_iterator(result.value())) {
6767
auto header_value = recorder::RecordingReader::is_header_valid(file.path());
6868
if (header_value.has_value()) {
69-
this->currently_chosen_files.push_back(file.path());
69+
this->m_currently_chosen_files.push_back(file.path());
7070
}
7171
}
7272
}
@@ -116,14 +116,14 @@ helper::BoolWrapper<std::pair<ui::EventHandleType, ui::Widget*>> custom_ui::Reco
116116

117117
[[nodiscard]] const std::vector<std::filesystem::path>& custom_ui::RecordingFileChooser::get_currently_chosen_files(
118118
) const {
119-
return currently_chosen_files;
119+
return m_currently_chosen_files;
120120
}
121121

122122
//TODO(Totto): solve in another way, that is better
123123
void custom_ui::RecordingFileChooser::prepare_dialog(ServiceProvider* service_provider) {
124124

125125
//TODO(Totto): show scene on top, that hints of the dialog
126-
this->currently_chosen_files.clear();
126+
this->m_currently_chosen_files.clear();
127127
service_provider->event_dispatcher().disable();
128128
}
129129

src/scenes/recording_selector/recording_chooser.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace custom_ui {
1616
struct RecordingFileChooser final : public ui::Widget, public ui::Focusable, public ui::Hoverable {
1717
private:
1818
ui::GridLayout m_main_grid;
19-
std::vector<std::filesystem::path> currently_chosen_files{};
19+
std::vector<std::filesystem::path> m_currently_chosen_files;
2020

2121
public:
2222
OOPETRIS_GRAPHICS_EXPORTED explicit RecordingFileChooser(

src/scenes/scene.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ namespace scenes {
1919
struct Scene {
2020
public:
2121
struct Switch {
22-
SceneId target_scene;
23-
ui::Layout layout;
22+
SceneId m_target_scene;
23+
ui::Layout m_layout;
2424

2525
Switch(const SceneId target_scene, const ui::Layout& layout)
26-
: target_scene{ target_scene },
27-
layout{ layout } { }
26+
: m_target_scene{ target_scene },
27+
m_layout{ layout } { }
2828
};
2929

3030
struct RawSwitch {
@@ -62,7 +62,8 @@ namespace scenes {
6262
using UpdateResult = std::pair<SceneUpdate, std::optional<Change>>;
6363

6464
protected:
65-
ServiceProvider* m_service_provider;
65+
ServiceProvider*
66+
m_service_provider; //NOLINT(misc-non-private-member-variables-in-classes,cppcoreguidelines-non-private-member-variables-in-classes)
6667

6768
private:
6869
ui::Layout m_layout;

0 commit comments

Comments
 (0)