From fbf846abc928b2b8558bc4c0091befa7b8521a6e Mon Sep 17 00:00:00 2001 From: HungryProton Date: Thu, 21 Oct 2021 20:59:15 +0200 Subject: [PATCH] fix every warning accross the entire addon --- plugin.gd | 4 ++++ src/common/poisson_disc_sampling.gd | 4 ++-- src/core/scatter.gd | 2 +- src/core/scatter_exclude_path.gd | 1 + src/core/scatter_item.gd | 11 ----------- src/core/scatter_path.gd | 3 ++- src/core/transforms.gd | 2 +- src/modifiers/add_around_point_grid.gd | 5 ++--- src/modifiers/base_modifier.gd | 2 +- src/modifiers/base_point_modifier.gd | 2 +- src/modifiers/clusterize.gd | 4 ++-- src/modifiers/distribute_along_even.gd | 2 +- src/modifiers/distribute_inside_grid.gd | 4 ++-- src/modifiers/randomize_rotation.gd | 5 ++--- .../modifier_stack_plugin.gd | 2 +- .../ui/add_modifier_button.gd | 2 -- .../ui/components/base_parameter.gd | 6 +++--- .../ui/components/curve_panel.gd | 2 ++ .../ui/components/parameter_bitmask.gd | 2 ++ .../ui/components/parameter_bool.gd | 1 + .../ui/components/parameter_scalar.gd | 2 ++ .../ui/components/parameter_vector2.gd | 2 ++ .../ui/modifier_panel.gd | 1 + .../ui/presets_button.gd | 6 ++++-- .../ui/stack_panel.gd | 17 ++++++++++------- .../path_gizmo/scatter_path_gizmo_plugin.gd | 1 - 26 files changed, 50 insertions(+), 45 deletions(-) diff --git a/plugin.gd b/plugin.gd index 2fb15b0..f9130b7 100644 --- a/plugin.gd +++ b/plugin.gd @@ -61,6 +61,8 @@ func _enter_tree(): _editor_selection = get_editor_interface().get_selection() _editor_selection.connect("selection_changed", self, "_on_selection_changed") + + # warning-ignore:return_value_discarded connect("scene_changed", self, "_on_scene_changed") @@ -137,6 +139,8 @@ func _setup_options_panel() -> void: ]) _gizmo_options = preload("./src/tools/path_gizmo/gizmo_options.tscn").instance() _options_root.add_child(_gizmo_options) + + # warning-ignore:return_value_discarded _gizmo_options.connect("snap_to_colliders_enabled", self, "_on_snap_to_colliders_enabled") _gizmo_options.visible = false diff --git a/src/common/poisson_disc_sampling.gd b/src/common/poisson_disc_sampling.gd index 4962196..f23ba9f 100644 --- a/src/common/poisson_disc_sampling.gd +++ b/src/common/poisson_disc_sampling.gd @@ -149,8 +149,8 @@ func _init_vars() -> void: push_error("Unrecognized shape!!! Please input a valid shape") _cell_size = _radius / sqrt(2) - _cols = max(floor(_sample_region_rect.size.x / _cell_size), 1) - _rows = max(floor(_sample_region_rect.size.y / _cell_size), 1) + _cols = int(max(floor(_sample_region_rect.size.x / _cell_size), 1)) + _rows = int(max(floor(_sample_region_rect.size.y / _cell_size), 1)) # scale the cell size in each axis _cell_size_scaled.x = _sample_region_rect.size.x / _cols _cell_size_scaled.y = _sample_region_rect.size.y / _rows diff --git a/src/core/scatter.gd b/src/core/scatter.gd index b436e43..3b62a16 100644 --- a/src/core/scatter.gd +++ b/src/core/scatter.gd @@ -65,7 +65,7 @@ func _get(property): return null -func _set(property, value): +func _set(property, _value): if not Engine.editor_hint: return false diff --git a/src/core/scatter_exclude_path.gd b/src/core/scatter_exclude_path.gd index c77960b..b0da896 100644 --- a/src/core/scatter_exclude_path.gd +++ b/src/core/scatter_exclude_path.gd @@ -3,6 +3,7 @@ extends "scatter_path.gd" func _ready(): + # warning-ignore:return_value_discarded connect("curve_updated", self, "update") diff --git a/src/core/scatter_item.gd b/src/core/scatter_item.gd index 16c2832..130e379 100644 --- a/src/core/scatter_item.gd +++ b/src/core/scatter_item.gd @@ -178,17 +178,6 @@ func update_shadows() -> void: return mmi.cast_shadow = cast_shadow - return - - match cast_shadow: - 0: - mmi.cast_shadows = GeometryInstance.SHADOW_CASTING_SETTING_OFF - 1: - mmi.cast_shadows = GeometryInstance.SHADOW_CASTING_SETTING_ON - 2: - mmi.cast_shadows = GeometryInstance.SHADOW_CASTING_SETTING_DOUBLE_SIDED - 3: - mmi.cast_shadows = GeometryInstance.SHADOW_CASTING_SETTING_SHADOWS_ONLY func _get_mesh_from_scene(node): diff --git a/src/core/scatter_path.gd b/src/core/scatter_path.gd index 00db952..4548038 100644 --- a/src/core/scatter_path.gd +++ b/src/core/scatter_path.gd @@ -20,7 +20,8 @@ var _previous_transform: Transform func _ready(): set_notify_transform(true) - self.connect("curve_changed", self, "_on_curve_changed") + # warning-ignore:return_value_discarded + connect("curve_changed", self, "_on_curve_changed") _update_from_curve() diff --git a/src/core/transforms.gd b/src/core/transforms.gd index fad8922..874ca33 100644 --- a/src/core/transforms.gd +++ b/src/core/transforms.gd @@ -21,7 +21,7 @@ func remove(count: int) -> void: func resize(count: int) -> void: if max_count >= 0: - count = min(count, max_count) + count = int(min(count, max_count)) var size = list.size() if count > size: diff --git a/src/modifiers/add_around_point_grid.gd b/src/modifiers/add_around_point_grid.gd index 2968ab7..ad41d73 100644 --- a/src/modifiers/add_around_point_grid.gd +++ b/src/modifiers/add_around_point_grid.gd @@ -23,10 +23,9 @@ func _process_transforms(transforms, global_seed) -> void: var size = bounds_max - bounds_min var half_size = size * 0.5 var center: Vector3 = bounds_min + half_size - var width: int = ceil(size.x / x_spacing) - var length: int = ceil(size.z / z_spacing) + var width := int(ceil(size.x / x_spacing)) + var length := int(ceil(size.z / z_spacing)) var max_count: int = width * length - var gt = transforms.path.get_global_transform() for i in max_count: var pos = Vector3.ZERO diff --git a/src/modifiers/base_modifier.gd b/src/modifiers/base_modifier.gd index 104b396..096064d 100644 --- a/src/modifiers/base_modifier.gd +++ b/src/modifiers/base_modifier.gd @@ -46,7 +46,7 @@ func process_transforms(transforms, global_seed) -> void: # Override in inherited class -func _process_transforms(transforms, global_seed) -> void: +func _process_transforms(_transforms, _global_seed) -> void: pass diff --git a/src/modifiers/base_point_modifier.gd b/src/modifiers/base_point_modifier.gd index 54011a2..083853b 100644 --- a/src/modifiers/base_point_modifier.gd +++ b/src/modifiers/base_point_modifier.gd @@ -39,7 +39,7 @@ func is_inside(pos: Vector3, p) -> bool: return distance_to_point <= max_distance -func _process_transforms(transforms, global_seed) -> void: +func _process_transforms(transforms, _global_seed) -> void: if node_name.empty(): warning += "You must select a node for this modifier to work." _notify_warning_changed() diff --git a/src/modifiers/clusterize.gd b/src/modifiers/clusterize.gd index 6755335..5833be0 100644 --- a/src/modifiers/clusterize.gd +++ b/src/modifiers/clusterize.gd @@ -14,7 +14,7 @@ func _init() -> void: category = "Edit" -func _process_transforms(transforms, global_seed) -> void: +func _process_transforms(transforms, _global_seed) -> void: if not ResourceLoader.exists(mask): warning += "The specified file " + mask + " could not be loaded" return @@ -26,7 +26,7 @@ func _process_transforms(transforms, global_seed) -> void: return var image: Image = texture.get_data() - image.decompress() + var _err = image.decompress() image.lock() var width = image.get_width() diff --git a/src/modifiers/distribute_along_even.gd b/src/modifiers/distribute_along_even.gd index 285d960..2150e7e 100644 --- a/src/modifiers/distribute_along_even.gd +++ b/src/modifiers/distribute_along_even.gd @@ -21,7 +21,7 @@ func _init() -> void: func _process_transforms(transforms, _seed) -> void: var path = transforms.path var length: float = path.curve.get_baked_length() - var total_count: int = round(length / interval) + var total_count := int(round(length / interval)) var stepped_length: float = total_count * interval if total_count == 0: diff --git a/src/modifiers/distribute_inside_grid.gd b/src/modifiers/distribute_inside_grid.gd index e28937d..3bf2ba9 100644 --- a/src/modifiers/distribute_inside_grid.gd +++ b/src/modifiers/distribute_inside_grid.gd @@ -22,8 +22,8 @@ func _process_transforms(transforms, global_seed) -> void: var half_size = size * 0.5 var height: float = transforms.path.bounds_max.y - var width: int = ceil(size.x / x_spacing) - var length: int = ceil(size.z / z_spacing) + var width := int(ceil(size.x / x_spacing)) + var length := int(ceil(size.z / z_spacing)) var max_count: int = width * length transforms.resize(max_count) diff --git a/src/modifiers/randomize_rotation.gd b/src/modifiers/randomize_rotation.gd index 4f548d6..5bb7d3c 100644 --- a/src/modifiers/randomize_rotation.gd +++ b/src/modifiers/randomize_rotation.gd @@ -26,7 +26,6 @@ func _process_transforms(transforms, global_seed) -> void: var t: Transform var b: Basis - var s: Vector3 var gt: Transform = transforms.path.get_global_transform() var gb: Basis = gt.basis @@ -60,8 +59,8 @@ func _random_vec3() -> Vector3: return vec3 -func _random_angle(rotation: float, snap: float) -> float: - return deg2rad(stepify(_rng.randf_range(-1.0, 1.0) * rotation, snap)) +func _random_angle(rot: float, snap: float) -> float: + return deg2rad(stepify(_rng.randf_range(-1.0, 1.0) * rot, snap)) func _clamp_vector(vec3, vmin, vmax) -> Vector3: diff --git a/src/tools/modifier_stack_inspector_plugin/modifier_stack_plugin.gd b/src/tools/modifier_stack_inspector_plugin/modifier_stack_plugin.gd index 9c00db6..ac68498 100644 --- a/src/tools/modifier_stack_inspector_plugin/modifier_stack_plugin.gd +++ b/src/tools/modifier_stack_inspector_plugin/modifier_stack_plugin.gd @@ -14,7 +14,7 @@ func can_handle(object): return object is _namespace.Scatter -func parse_property(object, type, path, hint, hint_text, usage): +func parse_property(object, type, path, _hint, hint_text, _usage): if type == TYPE_OBJECT and hint_text == "ScatterModifierStack": var editor_property = _editor.new() editor_property.set_node(object) diff --git a/src/tools/modifier_stack_inspector_plugin/ui/add_modifier_button.gd b/src/tools/modifier_stack_inspector_plugin/ui/add_modifier_button.gd index 24650f7..fcb1bb8 100644 --- a/src/tools/modifier_stack_inspector_plugin/ui/add_modifier_button.gd +++ b/src/tools/modifier_stack_inspector_plugin/ui/add_modifier_button.gd @@ -1,8 +1,6 @@ tool extends Button -signal add_modifier - onready var _popup = $ModifiersPopup var _modifiers := [] diff --git a/src/tools/modifier_stack_inspector_plugin/ui/components/base_parameter.gd b/src/tools/modifier_stack_inspector_plugin/ui/components/base_parameter.gd index f6bc5dd..d71d5ed 100644 --- a/src/tools/modifier_stack_inspector_plugin/ui/components/base_parameter.gd +++ b/src/tools/modifier_stack_inspector_plugin/ui/components/base_parameter.gd @@ -8,11 +8,11 @@ var _previous var _locked := false -func set_parameter_name(text: String) -> void: +func set_parameter_name(_text: String) -> void: pass -func set_hint_string(hint: String) -> void: +func set_hint_string(_hint: String) -> void: pass @@ -27,7 +27,7 @@ func get_value(): pass -func _set_value(val): +func _set_value(_val): pass diff --git a/src/tools/modifier_stack_inspector_plugin/ui/components/curve_panel.gd b/src/tools/modifier_stack_inspector_plugin/ui/components/curve_panel.gd index b587e78..23a4b4e 100644 --- a/src/tools/modifier_stack_inspector_plugin/ui/components/curve_panel.gd +++ b/src/tools/modifier_stack_inspector_plugin/ui/components/curve_panel.gd @@ -1,3 +1,5 @@ +# warning-ignore-all:return_value_discarded + tool extends Control diff --git a/src/tools/modifier_stack_inspector_plugin/ui/components/parameter_bitmask.gd b/src/tools/modifier_stack_inspector_plugin/ui/components/parameter_bitmask.gd index e593ef0..7ae159e 100644 --- a/src/tools/modifier_stack_inspector_plugin/ui/components/parameter_bitmask.gd +++ b/src/tools/modifier_stack_inspector_plugin/ui/components/parameter_bitmask.gd @@ -47,6 +47,8 @@ func _ready() -> void: _popup.add_check_item(layer_name, _layer_count - 1 - i) _sync_popup_state() + + # warning-ignore:return_value_discarded _popup.connect("id_pressed", self, "_on_id_pressed") diff --git a/src/tools/modifier_stack_inspector_plugin/ui/components/parameter_bool.gd b/src/tools/modifier_stack_inspector_plugin/ui/components/parameter_bool.gd index 302c788..e4a6f79 100644 --- a/src/tools/modifier_stack_inspector_plugin/ui/components/parameter_bool.gd +++ b/src/tools/modifier_stack_inspector_plugin/ui/components/parameter_bool.gd @@ -7,6 +7,7 @@ onready var _check_box: CheckBox = $CheckBox func _ready() -> void: + # warning-ignore:return_value_discarded _check_box.connect("toggled", self, "_on_value_changed") diff --git a/src/tools/modifier_stack_inspector_plugin/ui/components/parameter_scalar.gd b/src/tools/modifier_stack_inspector_plugin/ui/components/parameter_scalar.gd index f01794f..16d8794 100644 --- a/src/tools/modifier_stack_inspector_plugin/ui/components/parameter_scalar.gd +++ b/src/tools/modifier_stack_inspector_plugin/ui/components/parameter_scalar.gd @@ -1,3 +1,5 @@ +# warning-ignore-all:return_value_discarded + tool extends "base_parameter.gd" diff --git a/src/tools/modifier_stack_inspector_plugin/ui/components/parameter_vector2.gd b/src/tools/modifier_stack_inspector_plugin/ui/components/parameter_vector2.gd index a15208a..4355b3d 100644 --- a/src/tools/modifier_stack_inspector_plugin/ui/components/parameter_vector2.gd +++ b/src/tools/modifier_stack_inspector_plugin/ui/components/parameter_vector2.gd @@ -1,3 +1,5 @@ +# warning-ignore-all:return_value_discarded + tool extends "base_parameter.gd" diff --git a/src/tools/modifier_stack_inspector_plugin/ui/modifier_panel.gd b/src/tools/modifier_stack_inspector_plugin/ui/modifier_panel.gd index 599e18a..90a66ab 100644 --- a/src/tools/modifier_stack_inspector_plugin/ui/modifier_panel.gd +++ b/src/tools/modifier_stack_inspector_plugin/ui/modifier_panel.gd @@ -21,6 +21,7 @@ onready var _warning_popup: AcceptDialog = $AcceptDialog func _ready() -> void: + # warning-ignore:return_value_discarded _margin_container.connect("resized", self, "_on_child_resized") diff --git a/src/tools/modifier_stack_inspector_plugin/ui/presets_button.gd b/src/tools/modifier_stack_inspector_plugin/ui/presets_button.gd index 29301bf..a7b7446 100644 --- a/src/tools/modifier_stack_inspector_plugin/ui/presets_button.gd +++ b/src/tools/modifier_stack_inspector_plugin/ui/presets_button.gd @@ -12,11 +12,13 @@ var _save_popup: WindowDialog func _ready() -> void: _popup = get_popup() _popup.clear() + + # warning-ignore:return_value_discarded _popup.connect("id_pressed", self, "_on_id_pressed") - + _popup.add_icon_item(_save_icon, "Save Preset", 0) _popup.add_icon_item(_load_icon, "Load Preset", 1) - + _load_popup = get_node("LoadPresetPopup") _save_popup = get_node("SavePresetPopup") diff --git a/src/tools/modifier_stack_inspector_plugin/ui/stack_panel.gd b/src/tools/modifier_stack_inspector_plugin/ui/stack_panel.gd index 5a66de8..fcafd10 100644 --- a/src/tools/modifier_stack_inspector_plugin/ui/stack_panel.gd +++ b/src/tools/modifier_stack_inspector_plugin/ui/stack_panel.gd @@ -10,14 +10,17 @@ var _root: Control var _scatter var _modifier_stack var _modifier_panel = preload("./modifier_panel.tscn") -var _ready := false +var _is_ready := false func _ready(): _modifiers_popup = get_node(modifiers_popup) _root = get_node(root) + + # warning-ignore:return_value_discarded _modifiers_popup.connect("add_modifier", self, "_on_add_modifier") - _ready = true + + _is_ready = true rebuild_ui() @@ -30,7 +33,7 @@ func set_node(node) -> void: func rebuild_ui() -> void: - if not _ready: + if not _is_ready: return _validate_stack_connections() @@ -68,11 +71,11 @@ func _validate_stack_connections() -> void: _on_load_preset("default") -func _set_children_owner(root: Node, node: Node): +func _set_children_owner(new_owner: Node, node: Node): for child in node.get_children(): - child.set_owner(root) + child.set_owner(new_owner) if child.get_children().size() > 0: - _set_children_owner(root, child) + _set_children_owner(new_owner, child) func _get_root_folder() -> String: @@ -126,7 +129,7 @@ func _on_save_preset(preset_name) -> void: return var preset_path = _get_root_folder() + "/presets/" + preset_name + ".tscn" - ResourceSaver.save(preset_path, packed_scene) + var _err= ResourceSaver.save(preset_path, packed_scene) func _on_load_preset(preset_name) -> void: diff --git a/src/tools/path_gizmo/scatter_path_gizmo_plugin.gd b/src/tools/path_gizmo/scatter_path_gizmo_plugin.gd index db61f71..05d1b23 100644 --- a/src/tools/path_gizmo/scatter_path_gizmo_plugin.gd +++ b/src/tools/path_gizmo/scatter_path_gizmo_plugin.gd @@ -402,7 +402,6 @@ func _on_curve_changed() -> void: var previous_count: int = _previous_state.point_count var previous_pos: Vector3 = _previous_state.position - var previous_version: int = _previous_state.version _previous_state.point_count = current_count _previous_state.position = current_position