Skip to content

MNT Set up vulture and remove dead code it flagged#65

Open
mvdoc wants to merge 2 commits into
mainfrom
claude/setup-vulture-dead-code-uyOoR
Open

MNT Set up vulture and remove dead code it flagged#65
mvdoc wants to merge 2 commits into
mainfrom
claude/setup-vulture-dead-code-uyOoR

Conversation

@mvdoc
Copy link
Copy Markdown
Contributor

@mvdoc mvdoc commented May 16, 2026

Summary

  • Add vulture configuration in pyproject.toml (paths, min_confidence 80, ignore_names = ["kwargs", "trim"] to suppress the backend **kwargs interface pattern and the documented backward-compat trim no-op in viz.plot_patch) plus .vulture_whitelist.py for pytest fixtures that are looked up by name rather than imported.
  • Pin vulture>=2.14 in the dev dependency group. Running vulture from the repo root now exits 0.
  • Remove the unambiguous dead code the initial scan surfaced:
    • cmd_default in cli.py (dispatch happens via argparse subcommand, nothing called it).
    • Write-only best_conn local in core.py.
    • Unused loop variable r_iter_ in flatten/algorithm.py.
    • Unused call import in tests/test_core.py.
    • Lambda params subj_subj in tests/test_freesurfer.py (monkeypatch.setattr callbacks that ignore their argument).
  • Remove unreferenced public helpers in the flatten/ subpackage (not in __all__, no callers anywhere):
    • SurfaceFlattener.compute_distance_error / count_flipped — wrappers duplicating _compute_distance_error_jit and count_flipped_triangles that the algorithm uses directly.
    • setup_heat_geodesic / compute_heat_distance — heat-method path never wired into the pipeline; the production code uses graph Dijkstra.
    • compute_graph_distance — single-source variant superseded by compute_kring_geodesic_distances.
    • compute_both_energies_edges — edge-list variant superseded by the k-ring vectorized energy functions.
  • Trim distance.py's module docstring and section header now that the heat-method block is gone.

Test plan

  • vulture (run from repo root) exits 0
  • vulture autoflatten scripts --exclude "autoflatten/_version.py,autoflatten/tests/" exits 0 (no API-level dead code remaining)
  • pytest passes (the removed functions had no tests; the renamed lambda params and dropped call import keep test semantics identical)
  • autoflatten --help still lists all subcommands (run, project, flatten, plot-flatmap, plot-projection, render-snapshots)

Generated by Claude Code

claude added 2 commits May 16, 2026 16:49
Add vulture configuration in pyproject.toml plus a whitelist file for
pytest fixtures and other dynamically-referenced names. Running `vulture`
with no args now exits cleanly.

Also clean up the unambiguous dead code that the initial scan flagged:
- Remove unused cmd_default in cli.py (dispatch is by argparse subcommand)
- Drop write-only best_conn local in core.py
- Rename unused loop var r_iter -> _ in flatten/algorithm.py
- Drop unused `call` import in tests/test_core.py
- Rename ignored lambda params subj -> _subj in tests/test_freesurfer.py
These functions are not referenced anywhere in the package (nor exported
from flatten/__init__.py) and have no callers:

- SurfaceFlattener.compute_distance_error / count_flipped: wrapper methods
  duplicating the private _compute_distance_error_jit and
  count_flipped_triangles helpers that the algorithm actually uses.
- setup_heat_geodesic / compute_heat_distance: heat-method alternative
  never wired into the pipeline; production uses graph Dijkstra.
- compute_graph_distance: single-source variant superseded by the batched
  compute_kring_geodesic_distances path.
- compute_both_energies_edges: edge-list variant superseded by the k-ring
  vectorized energy functions.

Also trims distance.py's module docstring and section header now that the
heat-method block is gone.
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request focuses on code cleanup and the integration of the Vulture static analysis tool. It removes various unused functions, variables, and imports across the codebase, including the removal of the heat method for distance computation and several unused utility methods. Additionally, it configures Vulture in pyproject.toml and introduces a whitelist for pytest fixtures. Feedback suggests that the scripts directory included in the Vulture configuration may not exist, potentially causing the tool to fail.

Comment thread pyproject.toml
check-hidden = true

[tool.vulture]
paths = ["autoflatten", "scripts", ".vulture_whitelist.py"]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The scripts directory is included in the vulture configuration but does not appear to exist in the repository. This may cause vulture to fail.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scripts/ does exist — it contains 4 Python files (demo_flatten_animation.py, make_fsaverage_cut_template.py, make_subject_cut_template.py, plot_all_flatmaps.py). Including it in the vulture paths is intentional: it lets vulture see that helper functions like setup_freesurfer, identify_surface_components, and save_json are referenced (only from these scripts), so they don't get flagged as dead. vulture runs to completion with exit code 0 against the current config.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants