Skip to content

Delete the private functions and fields nothing used - #644

Merged
saworbit merged 3 commits into
mainfrom
fix/delete-dead-declarations
Sep 16, 2026
Merged

saworbit merged 3 commits into
mainfrom
fix/delete-dead-declarations

Conversation

@saworbit

Copy link
Copy Markdown
Owner

Fixes #609
Fixes #610

plugin.gd and level_root.gd are documented as thin coordinators whose named one-line delegates exist to be called by name, and the rule beside that is that a delegate with no caller gets deleted. Fifty-seven private functions and nine fields had drifted past it.

The lists were stale, so I re-derived them

The issue lists were taken a while ago and two of their own instructions no longer hold:

What was actually keeping this alive

Five architecture tests, and this is the more useful half of the finding.

Each enumerates a module's methods and asserts plugin.gd contains a delegation string for every one:

for method_name in ["can_drop_data", "drop_data", "is_entity_drag_data", ...]:
    assert_true(source.contains("HFPluginDropHandler.%s" % method_name))

Those lists had grown to include helpers the modules call themselves: update_preview, apply_value, do_displacement_stroke, point_near_polygon_3d, update_prefab_hover, move_selected_vertical, normalize_editor_selection, expand_native_group_selection, same_node_selection, sync_hf_selection_if_empty, face_screen_center, show_quick_property, ensure_vertex_overlay. The only way to satisfy the assertion was a wrapper nothing called, so tests written to keep plugin.gd thin were requiring it to be thicker.

I checked every one: all are reachable through entry points plugin.gd genuinely does delegate. Each list is now those entry points, and the drop test additionally asserts plugin.gd does not contain the payload type strings. That is what "thin delegate" was reaching for; the enumeration could pass while plugin.gd held a full duplicate of the classification.

Three that are more than dead weight

map_io.gd:_format_face_line is a drifted second copy of the .map face line. It takes three arguments and hard-codes the texture and the 0 0 0 1 1 tail; the three adapters take (a, b, c, texture, face_data) and read real UV data off FaceData. The signatures differ, so nothing could have called it even by accident, and a second copy of the export format is a trap for whoever fixes the exporter next.

LevelRoot.drag_active is a latent bug, not dead weight. Its setter calls input_state.cancel(); the canonical cancel_drag() is input_state.cancel() and _clear_preview(). So drag_active = false did half a cancel and left the preview brush orphaned in the scene. It is public on a registered custom type, so anyone who found it got the broken half.

DraftEntity.entity_properties was a second public name for entity_data that nothing used. Two names for one dictionary can only diverge.

Both public deletions are a break for any script that touched them, which is stated here rather than buried.

Deleting exposed one more layer, which is also gone

HFPluginSelectionState.selection_has_brush() and selection_has_entity() had exactly one caller each: the dead plugin.gd wrapper. Removing it made them provably dead, so they went in the same pass.

Re-running the scan afterwards finds zero function candidates and zero field candidates, so there is no third layer.

grid_plane_axis and _entity_props_entity were written and never read, so the writes in hf_grid_system.gd and dock_entity_handler.gd went with the declarations — deleting only the declarations would have left assignments to properties that no longer exist.

Docs

CHANGELOG. Nothing else goes stale: the four references in DEVELOPMENT.md and ROADMAP.md all point at the live plugin_drop_handler.gd or the adapter base's format_face_line.

The viewport drop path was a duplicate: plugin_drop_handler.gd is the live
one, reached through the two Godot virtuals, and it dispatches the four
payload kinds itself. The eight wrappers in front of that dispatch had no
caller.

Four architecture tests were keeping these alive. Each enumerates module
methods and asserts plugin.gd contains a delegation string for every one,
and the lists had grown to include helpers the modules call themselves:
update_preview, apply_value, do_displacement_stroke, point_near_polygon_3d,
update_prefab_hover, move_selected_vertical. The only way to satisfy that was
a wrapper nothing called.

The lists are now the entry points plugin.gd actually owns. The drop test
also asserts plugin.gd does not classify the payloads itself, which is the
property "thin delegate" was reaching for and the old list did not check.
Twenty in dock.gd, eight in level_root.gd, and seven elsewhere, plus the nine
fields from #610.

map_io.gd's _format_face_line was a drifted second copy of the .map face
line. It takes three arguments and hard-codes the texture and the 0 0 0 1 1
tail; the three adapters take (a, b, c, texture, face_data) and read real UV
data off FaceData. Nothing could have called it even by accident.

drag_active was worse than unused. Its setter called input_state.cancel()
while cancel_drag() is input_state.cancel() and _clear_preview(), so setting
it false did half a cancel and orphaned the preview brush. It is public on a
registered custom type, so anyone who found it got the broken half.

grid_plane_axis and _entity_props_entity were written and never read, so the
writes went with the declarations.

selection_has_brush and selection_has_entity became provably dead once their
only caller, a dead plugin.gd wrapper, was gone. Rerunning the scan afterwards
finds no third layer: zero functions, zero fields.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 16, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-16T23:36:58.284266Z c392921 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added area: build Brushes, drawing, vertex/edge editing (Build tab) area: objects Entities, prefabs, I/O wiring (Objects tab) area: architecture Subsystem structure, decomposition, code quality area: docs README, guides, spec, roadmap, changelog tests The GUT suite and its fixtures labels Sep 16, 2026
@saworbit
saworbit merged commit 837a44f into main Sep 16, 2026
5 checks passed
@saworbit
saworbit deleted the fix/delete-dead-declarations branch September 16, 2026 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: architecture Subsystem structure, decomposition, code quality area: build Brushes, drawing, vertex/edge editing (Build tab) area: docs README, guides, spec, roadmap, changelog area: objects Entities, prefabs, I/O wiring (Objects tab) tests The GUT suite and its fixtures

Projects

None yet

1 participant