Skip to content

Commit c008988

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

File tree

14 files changed

+27
-30
lines changed

14 files changed

+27
-30
lines changed

src/game/tetrion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Tetrion::Tetrion(
2424
: ui::Widget{ layout , ui::WidgetType::Component ,is_top_level},
2525
SimulatedTetrion{tetrion_index,random_seed,starting_level, service_provider,std::move(recording_writer)},
2626
m_main_layout{
27-
utils::size_t_identity<2>(),
27+
utils::SizeIdentity<2>(),
2828
0,
2929
ui::Direction::Vertical,
3030
{ 0.85 },

src/libs/core/helper/point.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ namespace shapes {
7676

7777
assert(x >= static_cast<T>(0) && y >= static_cast<T>(0) && "cast invalid, value to small");
7878
assert(static_cast<S>(x) <= std::numeric_limits<S>::max()
79-
&& static_cast<S>(y) >= std::numeric_limits<S>::max() && "cast invalid, value to big");
79+
&& static_cast<S>(y) <= std::numeric_limits<S>::max() && "cast invalid, value to big");
8080

8181
} else {
8282
// source is unsigned, destination is signed, so only the max check is necessary
8383

84-
assert(x <= std::numeric_limits<S>::max() && y >= std::numeric_limits<S>::max()
84+
assert(x <= std::numeric_limits<S>::max() && y <= std::numeric_limits<S>::max()
8585
&& "cast invalid, value to big");
8686
}
8787
} else {
@@ -91,10 +91,10 @@ namespace shapes {
9191
assert(x >= std::numeric_limits<S>::min() && y >= std::numeric_limits<S>::min()
9292
&& "cast invalid, value to small");
9393
assert(static_cast<S>(x) <= std::numeric_limits<S>::max()
94-
&& static_cast<S>(y) >= std::numeric_limits<S>::max() && "cast invalid, value to big");
94+
&& static_cast<S>(y) <= std::numeric_limits<S>::max() && "cast invalid, value to big");
9595
} else {
9696
// both are unsigned, so no min check is necessary
97-
assert(x <= std::numeric_limits<S>::max() && y >= std::numeric_limits<S>::max()
97+
assert(x <= std::numeric_limits<S>::max() && y <= std::numeric_limits<S>::max()
9898
&& "cast invalid, value to big");
9999
}
100100
}

src/libs/core/helper/random.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct Random {
1818
OOPETRIS_CORE_EXPORTED Random();
1919
OOPETRIS_CORE_EXPORTED explicit Random(std::mt19937_64::result_type seed);
2020

21-
template<utils::integral Integer>
21+
template<std::integral Integer>
2222
[[nodiscard]] Integer random(const Integer upper_bound_exclusive) {
2323
auto distribution = std::uniform_int_distribution<Integer>{ 0, upper_bound_exclusive - 1 };
2424
return distribution(m_generator);

src/libs/core/helper/utils.hpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <bit>
77
#include <cassert>
88
#include <climits>
9+
#include <concepts>
910
#include <exception>
1011
#include <iostream>
1112
#include <limits>
@@ -26,14 +27,10 @@ namespace helper {
2627

2728

2829
namespace utils {
29-
// taken from llvm: https://github.com/llvm/llvm-project/blob/main/libcxx/include/__concepts/arithmetic.h#L27-L30
30-
// [concepts.arithmetic], arithmetic concepts
31-
template<class T>
32-
concept integral = std::is_integral_v<T>;
3330

34-
template<integral Integral>
31+
template<std::integral Integral>
3532
[[nodiscard]] constexpr Integral byte_swap(Integral value) noexcept {
36-
// based on source: slartibartswift
33+
// Note: based on source: slartibartswift
3734
auto result = Integral{};
3835
for (usize i = 0; i < sizeof(Integral); ++i) {
3936
result <<= CHAR_BIT;
@@ -43,15 +40,15 @@ namespace utils {
4340
return result;
4441
}
4542

46-
[[nodiscard]] constexpr auto to_little_endian(integral auto value) {
43+
[[nodiscard]] constexpr auto to_little_endian(std::integral auto value) {
4744
if constexpr (std::endian::native == std::endian::little) {
4845
return value;
4946
} else {
5047
return byte_swap(value);
5148
}
5249
}
5350

54-
[[nodiscard]] constexpr auto from_little_endian(integral auto value) {
51+
[[nodiscard]] constexpr auto from_little_endian(std::integral auto value) {
5552
return to_little_endian(value);
5653
}
5754

@@ -74,7 +71,7 @@ namespace utils {
7471
}
7572
#endif
7673
template<size_t T>
77-
struct size_t_identity {
74+
struct SizeIdentity {
7875
//using type = T;
7976
};
8077

src/libs/recordings/utility/checksum_helper.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct Sha256Stream {
1818

1919
Sha256Stream();
2020

21-
template<utils::integral Integral>
21+
template<std::integral Integral>
2222
Sha256Stream& operator<<(const Integral value) {
2323

2424
library_object.add(

src/libs/recordings/utility/helper.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace helper {
2929
template<typename Result>
3030
using ReadResult = helper::expected<Result, ReadError>;
3131

32-
template<utils::integral Integral>
32+
template<std::integral Integral>
3333
[[nodiscard]] ReadResult<std::remove_cv_t<Integral>> read_integral_from_file(std::ifstream& file) {
3434
if (not file) {
3535
return helper::unexpected<ReadError>{
@@ -78,7 +78,7 @@ namespace helper {
7878
return result;
7979
}
8080

81-
template<utils::integral Integral>
81+
template<std::integral Integral>
8282
[[nodiscard]] std::optional<Integral> read_from_istream(std::istream& istream) {
8383
if (not istream) {
8484
return std::nullopt;
@@ -123,7 +123,7 @@ namespace helper {
123123

124124
namespace writer {
125125

126-
template<utils::integral Integral>
126+
template<std::integral Integral>
127127
helper::expected<void, std::string> write_integral_to_file(std::ofstream& file, const Integral data) {
128128
if (not file) {
129129
return helper::unexpected<std::string>{ fmt::format("failed to write data \"{}\"", data) };
@@ -154,7 +154,7 @@ namespace helper {
154154
}
155155

156156

157-
template<utils::integral Integral>
157+
template<std::integral Integral>
158158
void append_value(std::vector<char>& vector, const Integral value) {
159159
const auto little_endian_value = utils::to_little_endian(value);
160160
const char* const start =

src/libs/recordings/utility/recording_writer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace recorder {
5151
const AdditionalInformation& information
5252
);
5353

54-
template<utils::integral Integral>
54+
template<std::integral Integral>
5555
helper::expected<void, std::string> write(Integral data) {
5656
const auto result = helper::writer::write_integral_to_file(m_output_file, data);
5757
if (not result.has_value()) {

src/scenes/about_page/about_page.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ namespace scenes {
6767

6868

6969
const auto tile_layout_index = m_main_grid.add<ui::TileLayout>(
70-
utils::size_t_identity<2>(), focus_helper.focus_id(), ui::Direction::Horizontal,
70+
utils::SizeIdentity<2>(), focus_helper.focus_id(), ui::Direction::Horizontal,
7171
std::array<double, 1>{ 0.85 }, ui::AbsolutMargin{ 0 }, std::pair<double, double>{ 0.05, 0.03 }
7272
);
7373

src/scenes/online_lobby/online_lobby.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace scenes {
1919
OnlineLobby::OnlineLobby(ServiceProvider* service_provider, const ui::Layout& layout)
2020
: Scene{ service_provider, layout },
2121
m_main_layout{
22-
utils::size_t_identity<3>(),
22+
utils::SizeIdentity<3>(),
2323
0,
2424
ui::Direction::Vertical,
2525
{ 0.1, 0.9 },

src/scenes/recording_selector/recording_component.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ custom_ui::RecordingComponent::RecordingComponent(
1919
):ui::Widget{layout, ui::WidgetType::Component, is_top_level},
2020
ui::Focusable{focus_helper.focus_id()},
2121
ui::Hoverable{layout.get_rect()},
22-
m_main_layout{ utils::size_t_identity<2>(), focus_helper.focus_id(),
22+
m_main_layout{ utils::SizeIdentity<2>(), focus_helper.focus_id(),
2323
ui::Direction::Vertical,
2424
std::array<double, 1>{ 0.6 }, ui::RelativeMargin{layout.get_rect(), ui::Direction::Vertical,0.05}, std::pair<double, double>{ 0.05, 0.03 },
2525
layout,false
@@ -32,7 +32,7 @@ custom_ui::RecordingComponent::RecordingComponent(
3232
);
3333

3434
const auto information_layout_index = m_main_layout.add<ui::TileLayout>(
35-
utils::size_t_identity<3>(), focus_helper.focus_id(), ui::Direction::Horizontal,
35+
utils::SizeIdentity<3>(), focus_helper.focus_id(), ui::Direction::Horizontal,
3636
std::array<double, 2>{ 0.33, 0.66 }, ui::AbsolutMargin{ 10 }, std::pair<double, double>{ 0.05, 0.03 }
3737
);
3838

0 commit comments

Comments
 (0)