Skip to content

Commit 6130ed8

Browse files
committed
fix clang-tidy warnings
1 parent 2dbd94f commit 6130ed8

File tree

9 files changed

+18
-17
lines changed

9 files changed

+18
-17
lines changed

.clangd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CompileFlags:
2-
CompilationDatabase: build.cmake
2+
CompilationDatabase: build
33
Index:
44
StandardLibrary: Yes
55
Diagnostics:

clang-tidy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
22

3-
clang-tidy -header-filter=.* -p build.cmake include/gf2/**/*.h library/core/*.cc library/graphics/*.cc library/network/*.cc library/network/bits/* library/physics/*.cc library/imgui/*.cc examples/*.cc bin/*.cc games/**/*.cc games/**/**/*.h games/**/**/*.cc
3+
clang-tidy -header-filter=.* -p build include/gf2/**/*.h library/core/*.cc library/graphics/*.cc library/network/*.cc library/network/bits/* library/physics/*.cc library/imgui/*.cc examples/*.cc bin/*.cc games/**/*.cc games/**/**/*.h games/**/**/*.cc

games/HOME/bits/BackpackEntity.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ namespace home {
7979
}
8080
}
8181

82-
gf::Positioning positioning(m_hub->render_manager()->surface_size());
82+
const gf::Positioning positioning(m_hub->render_manager()->surface_size());
8383

8484
gf::ShapeGroupData shape_group_data;
8585

86-
gf::RectF backpack_bounds = gf::RectF::from_position_size(positioning.relative_point({ 0.95f, 0.18f }), positioning.relative_size({ 0.01f, 0.72f }));
86+
const gf::RectF backpack_bounds = gf::RectF::from_position_size(positioning.relative_point({ 0.95f, 0.18f }), positioning.relative_size({ 0.01f, 0.72f }));
8787

8888
gf::ShapeData back_shape_data = gf::ShapeData::make_rectangle(backpack_bounds);
8989
back_shape_data.color = gf::Black * gf::opaque(0.3f);
@@ -98,8 +98,8 @@ namespace home {
9898
continue;
9999
}
100100

101-
float supply_percent = static_cast<float>(supply.quantity) / static_cast<float>(LimitBackpack);
102-
float supply_height = backpack_bounds.extent.h * supply_percent;
101+
const float supply_percent = static_cast<float>(supply.quantity) / static_cast<float>(LimitBackpack);
102+
const float supply_height = backpack_bounds.extent.h * supply_percent;
103103
supply_position.y -= supply_height;
104104

105105
auto color = to_color(supply.type);
@@ -112,7 +112,7 @@ namespace home {
112112
}
113113

114114
gf::RectF oxygen_bounds = gf::RectF::from_position_size(positioning.relative_point({ 0.04f, 0.18f }), positioning.relative_size({ 0.01f, 0.72f }));
115-
gf::Color oxygen_color = to_color(SupplyType::Oxygen);
115+
const gf::Color oxygen_color = to_color(SupplyType::Oxygen);
116116

117117
auto oxygen_percent = static_cast<float>(m_oxygen_quantity) / static_cast<float>(MaxOxygen);
118118

@@ -143,7 +143,7 @@ namespace home {
143143

144144
void BackpackEntity::render(gf::RenderRecorder& recorder)
145145
{
146-
gf::Positioning positioning(m_hub->render_manager()->surface_size());
146+
const gf::Positioning positioning(m_hub->render_manager()->surface_size());
147147

148148
auto icon_size = positioning.relative_size({ 0.04f, 0.0f });
149149

include/gf2/core/AnimationData.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace gf {
2222
struct GF_CORE_API AnimationFrameData {
2323
uint32_t texture_index = 0;
2424
RectF texture_region = RectF::from_size({ 0.0f, 0.0f });
25-
Time duration = {};
25+
Time duration;
2626
};
2727

2828
template<typename Archive>

include/gf2/core/Circ.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ namespace gf {
3333
return radius == T(0);
3434
}
3535

36-
inline bool contains(Vec2<T> point) const noexcept
36+
constexpr bool contains(Vec2<T> point) const noexcept
3737
{
3838
return gf::square_distance(center, point) <= gf::square(radius);
3939
}
4040

41-
inline bool intersects(Circ other) const noexcept
41+
constexpr bool intersects(Circ other) const noexcept
4242
{
4343
return gf::square_distance(center, other.center) <= gf::square(radius + other.radius);
4444
}

include/gf2/core/Math.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ namespace gf {
123123
template<typename T>
124124
constexpr T clamp(T val, T lo, T hi)
125125
{
126-
return val < lo ? lo : (hi < val ? hi : val);
126+
return details::min(details::max(val, lo), hi);
127127
}
128128

129129
template<typename T>

include/gf2/graphics/Animation.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace gf {
2424

2525
struct GF_GRAPHICS_API AnimationFrameRuntime {
2626
std::size_t texture_index = 0;
27-
Time duration = {};
27+
Time duration;
2828
std::size_t offset = 0;
2929
};
3030

@@ -57,7 +57,7 @@ namespace gf {
5757

5858
AnimationRuntime m_animation;
5959
std::size_t m_current_frame = 0;
60-
Time m_current_time = {};
60+
Time m_current_time;
6161
};
6262

6363
class GF_GRAPHICS_API AnimationGroup {
@@ -90,7 +90,7 @@ namespace gf {
9090
std::map<Id, AnimationRuntime> m_animations;
9191
Id m_current_animation_id = InvalidId;
9292
std::size_t m_current_frame = 0;
93-
Time m_current_time = {};
93+
Time m_current_time;
9494
};
9595
}
9696

include/gf2/graphics/VertexInput.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ namespace gf {
2727
};
2828

2929
struct GF_GRAPHICS_API VertexInput {
30-
std::vector<VertexBinding> bindings = {};
31-
std::vector<VertexAttribute> attributes = {};
30+
std::vector<VertexBinding> bindings;
31+
std::vector<VertexAttribute> attributes;
3232
};
3333

3434
}

xmake.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ add_requires("vulkan-headers")
1313
add_requires("vulkan-memory-allocator")
1414

1515
add_rules("mode.coverage", "mode.debug", "mode.releasedbg", "mode.release")
16+
add_rules("plugin.compile_commands.autoupdate", {outputdir = "$(buildir)"})
1617

1718
if is_mode("sanitizers") then
1819
set_symbols("debug")

0 commit comments

Comments
 (0)