From 89a311205f20efd28faff8e4695bd1af730613ae Mon Sep 17 00:00:00 2001 From: Thaddeus Crews Date: Fri, 21 Jun 2024 11:19:04 -0500 Subject: [PATCH] Style: Apply `clang-tidy` fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • `modernize-use-default-member-init` and `readability-redundant-member-init` • Minor adjustments to `.clang-tidy` to improve syntax & remove redundancies --- .clang-tidy | 21 ++++++++----------- core/typedefs.h | 2 -- core/variant/variant.cpp | 12 ++++------- core/variant/variant.h | 3 +-- .../vulkan/rendering_device_driver_vulkan.cpp | 2 +- .../vulkan/rendering_device_driver_vulkan.h | 2 +- editor/editor_node.h | 2 +- editor/gui/editor_quick_open_dialog.cpp | 3 ++- .../tiles/tile_set_atlas_source_editor.h | 2 +- modules/betsy/image_compress_betsy.h | 4 ++-- modules/navigation/nav_agent.h | 2 +- .../openxr_extension_wrapper_extension.cpp | 3 +-- scene/3d/skeleton_3d.h | 2 +- scene/3d/skeleton_ik_3d.h | 2 +- scene/gui/code_edit.h | 6 +++--- scene/gui/text_edit.h | 2 +- .../skeleton/skeleton_modification_stack_2d.h | 2 +- scene/resources/2d/tile_set.h | 2 +- .../renderer_rd/storage_rd/texture_storage.h | 6 +++--- servers/rendering/shader_language.h | 2 +- tests/servers/test_navigation_server_3d.h | 2 +- 21 files changed, 37 insertions(+), 47 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 366781cc823..1eb974f3f86 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,14 +1,12 @@ ---- -Checks: >- - -*, - cppcoreguidelines-pro-type-member-init, - modernize-redundant-void-arg, - modernize-use-bool-literals, - modernize-use-default-member-init, - modernize-use-nullptr, - readability-braces-around-statements, - readability-redundant-member-init -WarningsAsErrors: '' +Checks: + - -* + - cppcoreguidelines-pro-type-member-init + - modernize-redundant-void-arg + - modernize-use-bool-literals + - modernize-use-default-member-init + - modernize-use-nullptr + - readability-braces-around-statements + - readability-redundant-member-init HeaderFileExtensions: ['', h, hh, hpp, hxx, inc, glsl] ImplementationFileExtensions: [c, cc, cpp, cxx, m, mm, java] HeaderFilterRegex: (core|doc|drivers|editor|main|modules|platform|scene|servers|tests)/ @@ -19,4 +17,3 @@ CheckOptions: modernize-use-bool-literals.IgnoreMacros: false modernize-use-default-member-init.IgnoreMacros: false modernize-use-default-member-init.UseAssignment: true -... diff --git a/core/typedefs.h b/core/typedefs.h index 85d62df96bb..35c4668581b 100644 --- a/core/typedefs.h +++ b/core/typedefs.h @@ -315,6 +315,4 @@ struct BuildIndexSequence<0, Is...> : IndexSequence {}; #define ___gd_is_defined(val) ____gd_is_defined(__GDARG_PLACEHOLDER_##val) #define GD_IS_DEFINED(x) ___gd_is_defined(x) -#define FORCE_SEMICOLON ; - #endif // TYPEDEFS_H diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp index 7550477d70e..65bfc29a555 100644 --- a/core/variant/variant.cpp +++ b/core/variant/variant.cpp @@ -2719,8 +2719,7 @@ Variant::Variant(const Vector &p_array) : } } -Variant::Variant(const Vector &p_face_array) : - type(NIL) { +Variant::Variant(const Vector &p_face_array) { PackedVector3Array vertices; int face_count = p_face_array.size(); vertices.resize(face_count * 3); @@ -2739,8 +2738,7 @@ Variant::Variant(const Vector &p_face_array) : *this = vertices; } -Variant::Variant(const Vector &p_array) : - type(NIL) { +Variant::Variant(const Vector &p_array) { Array arr; arr.resize(p_array.size()); for (int i = 0; i < p_array.size(); i++) { @@ -2749,8 +2747,7 @@ Variant::Variant(const Vector &p_array) : *this = arr; } -Variant::Variant(const Vector &p_array) : - type(NIL) { +Variant::Variant(const Vector &p_array) { PackedStringArray v; int len = p_array.size(); v.resize(len); @@ -2908,8 +2905,7 @@ Variant::Variant(const IPAddress &p_address) : memnew_placement(_data._mem, String(p_address)); } -Variant::Variant(const Variant &p_variant) : - type(NIL) { +Variant::Variant(const Variant &p_variant) { reference(p_variant); } diff --git a/core/variant/variant.h b/core/variant/variant.h index 3b1924e8eab..9702c67a371 100644 --- a/core/variant/variant.h +++ b/core/variant/variant.h @@ -814,8 +814,7 @@ public: static void unregister_types(); Variant(const Variant &p_variant); - _FORCE_INLINE_ Variant() : - type(NIL) {} + _FORCE_INLINE_ Variant() {} _FORCE_INLINE_ ~Variant() { clear(); } diff --git a/drivers/vulkan/rendering_device_driver_vulkan.cpp b/drivers/vulkan/rendering_device_driver_vulkan.cpp index f9f1168a97a..e109489f0c0 100644 --- a/drivers/vulkan/rendering_device_driver_vulkan.cpp +++ b/drivers/vulkan/rendering_device_driver_vulkan.cpp @@ -4017,7 +4017,7 @@ RDD::UniformSetID RenderingDeviceDriverVulkan::uniform_set_create(VectorViewvalue[vk_pool]++; diff --git a/drivers/vulkan/rendering_device_driver_vulkan.h b/drivers/vulkan/rendering_device_driver_vulkan.h index 33cce30b349..eeaefe43e7f 100644 --- a/drivers/vulkan/rendering_device_driver_vulkan.h +++ b/drivers/vulkan/rendering_device_driver_vulkan.h @@ -487,7 +487,7 @@ private: struct UniformSetInfo { VkDescriptorSet vk_descriptor_set = VK_NULL_HANDLE; VkDescriptorPool vk_descriptor_pool = VK_NULL_HANDLE; - DescriptorSetPools::Iterator pool_sets_it = {}; + DescriptorSetPools::Iterator pool_sets_it; }; public: diff --git a/editor/editor_node.h b/editor/editor_node.h index 39a4c7df651..49c1699c282 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -789,7 +789,7 @@ public: struct AdditiveNodeEntry { Node *node = nullptr; - NodePath parent = NodePath(); + NodePath parent; Node *owner = nullptr; int index = 0; // Used if the original parent node is lost diff --git a/editor/gui/editor_quick_open_dialog.cpp b/editor/gui/editor_quick_open_dialog.cpp index a6ad002de74..b8f3b259cab 100644 --- a/editor/gui/editor_quick_open_dialog.cpp +++ b/editor/gui/editor_quick_open_dialog.cpp @@ -649,8 +649,9 @@ QuickOpenDisplayMode QuickOpenResultContainer::get_adaptive_display_mode(const V for (const StringName &type : grid_preferred_types) { for (const StringName &base_type : p_base_types) { - if (base_type == type || ClassDB::is_parent_class(base_type, type)) + if (base_type == type || ClassDB::is_parent_class(base_type, type)) { return QuickOpenDisplayMode::GRID; + } } } diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.h b/editor/plugins/tiles/tile_set_atlas_source_editor.h index 39f2f51ef36..f8b65bd6759 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.h +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.h @@ -91,7 +91,7 @@ public: TileSetAtlasSourceEditor *tiles_set_atlas_source_editor = nullptr; Ref tile_set_atlas_source; - RBSet tiles = RBSet(); + RBSet tiles; protected: bool _set(const StringName &p_name, const Variant &p_value); diff --git a/modules/betsy/image_compress_betsy.h b/modules/betsy/image_compress_betsy.h index 4e0bf0538f1..ab7b7858030 100644 --- a/modules/betsy/image_compress_betsy.h +++ b/modules/betsy/image_compress_betsy.h @@ -91,10 +91,10 @@ class BetsyCompressor : public Object { RenderingDevice *compress_rd = nullptr; RenderingContextDriver *compress_rcd = nullptr; HashMap cached_shaders; - RID src_sampler = RID(); + RID src_sampler; // Format-specific resources. - RID dxt1_encoding_table_buffer = RID(); + RID dxt1_encoding_table_buffer; void _init(); void _assign_mt_ids(WorkerThreadPool::TaskID p_pump_task_id); diff --git a/modules/navigation/nav_agent.h b/modules/navigation/nav_agent.h index e3671504f2b..d56e053ac4c 100644 --- a/modules/navigation/nav_agent.h +++ b/modules/navigation/nav_agent.h @@ -67,7 +67,7 @@ class NavAgent : public NavRid { uint32_t avoidance_mask = 1; real_t avoidance_priority = 1.0; - Callable avoidance_callback = Callable(); + Callable avoidance_callback; bool agent_dirty = true; diff --git a/modules/openxr/extensions/openxr_extension_wrapper_extension.cpp b/modules/openxr/extensions/openxr_extension_wrapper_extension.cpp index 07ca476421d..c205e7f5bf1 100644 --- a/modules/openxr/extensions/openxr_extension_wrapper_extension.cpp +++ b/modules/openxr/extensions/openxr_extension_wrapper_extension.cpp @@ -298,8 +298,7 @@ void OpenXRExtensionWrapperExtension::register_extension_wrapper() { OpenXRAPI::register_extension_wrapper(this); } -OpenXRExtensionWrapperExtension::OpenXRExtensionWrapperExtension() : - Object(), OpenXRExtensionWrapper() { +OpenXRExtensionWrapperExtension::OpenXRExtensionWrapperExtension() { openxr_api.instantiate(); } diff --git a/scene/3d/skeleton_3d.h b/scene/3d/skeleton_3d.h index ecfe095f1de..90902f71e2f 100644 --- a/scene/3d/skeleton_3d.h +++ b/scene/3d/skeleton_3d.h @@ -162,7 +162,7 @@ private: Vector parentless_bones; AHashMap name_to_bone_index; - mutable StringName concatenated_bone_names = StringName(); + mutable StringName concatenated_bone_names; void _update_bone_names() const; void _make_dirty(); diff --git a/scene/3d/skeleton_ik_3d.h b/scene/3d/skeleton_ik_3d.h index 5d6020194e1..94145a69152 100644 --- a/scene/3d/skeleton_ik_3d.h +++ b/scene/3d/skeleton_ik_3d.h @@ -131,7 +131,7 @@ class SkeletonIK3D : public SkeletonModifier3D { real_t min_distance = 0.01; int max_iterations = 10; - Variant target_node_override_ref = Variant(); + Variant target_node_override_ref; FabrikInverseKinematic::Task *task = nullptr; #ifndef DISABLE_DEPRECATED diff --git a/scene/gui/code_edit.h b/scene/gui/code_edit.h index ab443e95e14..2cd34ec99f1 100644 --- a/scene/gui/code_edit.h +++ b/scene/gui/code_edit.h @@ -251,13 +251,13 @@ private: Ref completion_color_bg; Color breakpoint_color = Color(1, 1, 1); - Ref breakpoint_icon = Ref(); + Ref breakpoint_icon; Color bookmark_color = Color(1, 1, 1); - Ref bookmark_icon = Ref(); + Ref bookmark_icon; Color executing_line_color = Color(1, 1, 1); - Ref executing_line_icon = Ref(); + Ref executing_line_icon; Color line_number_color = Color(1, 1, 1); diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index e0d552848d5..6b137581f2f 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -139,7 +139,7 @@ private: Variant metadata; bool clickable = false; - Ref icon = Ref(); + Ref icon; String text = ""; Color color = Color(1, 1, 1); }; diff --git a/scene/resources/2d/skeleton/skeleton_modification_stack_2d.h b/scene/resources/2d/skeleton/skeleton_modification_stack_2d.h index 07321539970..d1e50cb702f 100644 --- a/scene/resources/2d/skeleton/skeleton_modification_stack_2d.h +++ b/scene/resources/2d/skeleton/skeleton_modification_stack_2d.h @@ -64,7 +64,7 @@ public: execution_mode_physics_process }; - Vector> modifications = Vector>(); + Vector> modifications; void setup(); void execute(float p_delta, int p_execution_mode); diff --git a/scene/resources/2d/tile_set.h b/scene/resources/2d/tile_set.h index 7979e2ca39a..8343c22b91b 100644 --- a/scene/resources/2d/tile_set.h +++ b/scene/resources/2d/tile_set.h @@ -836,7 +836,7 @@ private: bool flip_v = false; bool transpose = false; Vector2i texture_origin; - Ref material = Ref(); + Ref material; Color modulate = Color(1.0, 1.0, 1.0, 1.0); int z_index = 0; int y_sort_origin = 0; diff --git a/servers/rendering/renderer_rd/storage_rd/texture_storage.h b/servers/rendering/renderer_rd/storage_rd/texture_storage.h index b9acd0d7584..3d281cf98a2 100644 --- a/servers/rendering/renderer_rd/storage_rd/texture_storage.h +++ b/servers/rendering/renderer_rd/storage_rd/texture_storage.h @@ -102,9 +102,9 @@ private: /* Canvas Texture API */ struct CanvasTextureCache { - RID diffuse = RID(); - RID normal = RID(); - RID specular = RID(); + RID diffuse; + RID normal; + RID specular; }; class CanvasTexture { diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h index ddd4c410595..4dade4d79fd 100644 --- a/servers/rendering/shader_language.h +++ b/servers/rendering/shader_language.h @@ -1213,7 +1213,7 @@ public: struct ShaderCompileInfo { HashMap functions; Vector render_modes; - VaryingFunctionNames varying_function_names = VaryingFunctionNames(); + VaryingFunctionNames varying_function_names; HashSet shader_types; GlobalShaderUniformGetTypeFunc global_shader_uniform_type_func = nullptr; bool is_include = false; diff --git a/tests/servers/test_navigation_server_3d.h b/tests/servers/test_navigation_server_3d.h index 4411b1aae5c..1b2a5e0db29 100644 --- a/tests/servers/test_navigation_server_3d.h +++ b/tests/servers/test_navigation_server_3d.h @@ -49,7 +49,7 @@ public: } unsigned function1_calls{ 0 }; - Variant function1_latest_arg0{}; + Variant function1_latest_arg0; }; static inline Array build_array() {