Skip to content

Commit a9b0ea2

Browse files
committed
Fix clang-tidy warnings and update config
1 parent 2693964 commit a9b0ea2

7 files changed

Lines changed: 22 additions & 8 deletions

File tree

.clang-tidy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Checks:
1010
- -cppcoreguidelines-avoid-non-const-global-variables
1111
- -cppcoreguidelines-owning-memory
1212
- -cppcoreguidelines-non-private-member-variables-in-classes
13+
- -cppcoreguidelines-pro-type-union-access # False positives when accessing Vector2 coordinates
14+
- -cppcoreguidelines-use-default-member-init
1315
- misc-*
1416
- -misc-non-private-member-variables-in-classes
1517
- -misc-use-anonymous-namespace
@@ -24,3 +26,5 @@ Checks:
2426
- -readability-implicit-bool-conversion
2527
- -readability-math-missing-parentheses
2628
- -readability-avoid-unconditional-preprocessor-if
29+
CheckOptions:
30+
performance-unnecessary-value-param.AllowedTypes: Ref

.clangd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ CompileFlags:
44
Add:
55
- -Wall
66
- -Wextra
7+
Diagnostics:
8+
ClangTidy:
9+
FastCheckFilter: None

run_clang_tidy.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@
22

33
cd "$(dirname "$(readlink -f "$0")")" || exit 1
44

5-
clang-tidy src/*.cpp --config-file .clang-tidy -p .
5+
echo "Checks: '-*'" > ./godot-cpp/.clang-tidy
6+
7+
if [ -t 0 ]; then
8+
run-clang-tidy -header-filter=src/ -allow-no-checks -use-color 1 -quiet "$@"
9+
else
10+
run-clang-tidy -header-filter=src/ -allow-no-checks -quiet "$@"
11+
fi

src/NativeRopeServer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void NativeRopeServer::register_rope(Node2D* rope)
5959

6060
void NativeRopeServer::unregister_rope(Node2D* rope)
6161
{
62-
const int idx = _ropes.find(rope);
62+
const int64_t idx = _ropes.find(rope);
6363

6464
if (idx < 0)
6565
{
@@ -68,7 +68,7 @@ void NativeRopeServer::unregister_rope(Node2D* rope)
6868
}
6969

7070
// Swap and pop
71-
const int last_idx = _ropes.size() - 1;
71+
const int64_t last_idx = _ropes.size() - 1;
7272
_ropes.set(idx, _ropes[last_idx]);
7373
_ropes.remove_at(last_idx);
7474

@@ -151,7 +151,7 @@ float NativeRopeServer::get_computation_time() const
151151
return _last_time;
152152
}
153153

154-
int NativeRopeServer::get_num_ropes() const
154+
int64_t NativeRopeServer::get_num_ropes() const
155155
{
156156
return _ropes.size();
157157
}

src/NativeRopeServer.hpp

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

99
namespace godot
1010
{
11-
class NativeRopeServer : public Object
11+
class NativeRopeServer : public Object // NOLINT(cppcoreguidelines-special-member-functions)
1212
{
1313
GDCLASS(NativeRopeServer, Object) // NOLINT
1414

@@ -24,7 +24,7 @@ namespace godot
2424
void set_update_in_editor(bool value);
2525
bool get_update_in_editor() const;
2626

27-
int get_num_ropes() const;
27+
int64_t get_num_ropes() const;
2828
float get_computation_time() const;
2929

3030
protected:

src/RopeWindParameters.hpp

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

77
namespace godot
88
{
9-
class RopeWindParameters : public Resource
9+
class RopeWindParameters : public Resource // NOLINT(cppcoreguidelines-special-member-functions)
1010
{
1111
GDCLASS(RopeWindParameters, Resource) // NOLINT
1212

@@ -36,4 +36,4 @@ namespace godot
3636
};
3737
}
3838

39-
#endif
39+
#endif

src/gdlibrary.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ void uninitialize_libropesim(ModuleInitializationLevel p_level) {
3535

3636
extern "C" {
3737
// Initialization.
38+
// NOLINTNEXTLINE(misc-misplaced-const)
3839
GDExtensionBool GDE_EXPORT libropesim_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
3940
const godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization);
4041

0 commit comments

Comments
 (0)