igniter icon indicating copy to clipboard operation
igniter copied to clipboard

`Igniter.Refactors.Rename.rename_function/4` is a no-op once `Igniter.include_all_elixir_files/1` has run

Open MaxSvargal opened this issue 4 weeks ago • 0 comments

Checked before writing (2026-11-05)

  • The latest release on hex.pm is 0.8.5, the version we lock.
  • CHANGELOG.md of 0.8.5 has no entry about update_all_elixir_files or rename_function after an include-all.
  • main on GitHub, read on 2026-11-05: Igniter.update_all_elixir_files/2 (lib/igniter.ex, line 1118) still returns the igniter unchanged when included_all_elixir_files? is set. Not fixed upstream.

Environment

From our mix.lock: igniter 0.8.5, rewrite 1.3.0, sourceror 1.13.0. Elixir 1.20.4, Erlang/OTP 29.

What happens

rename_function/4 rewrites calls through Igniter.update_all_elixir_files/2. That function begins:

if igniter.assigns[:private][:included_all_elixir_files?] do
  igniter
else
  # ... update_glob over the source folders, test and config ...
  |> assign_private(:included_all_elixir_files?, true)
end

include_all_elixir_files/1 sets the same private flag. So after an include-all, update_all_elixir_files/2 returns without running the updater, and every caller of it does nothing: rename_function/4, and any second update_all_elixir_files/2 call in the same igniter. No warning or notice is raised; the rename silently does not happen. From reading the code (not run): the definition's own rewrite goes through Igniter.Project.Module.find_module/2, not this path, so with deprecate: unset a definition can be moved while its callers keep the old name.

Minimal reproduction

Save as repro.exs and run elixir repro.exs:

Mix.install([{:igniter, "0.8.5"}])

source = """
defmodule Caller do
  def go, do: Old.call(1)
end
"""

rename = fn igniter ->
  igniter
  |> Igniter.Refactors.Rename.rename_function({Old, :call}, {New, :call}, arity: 1)
  |> Map.fetch!(:rewrite)
  |> Rewrite.source!("lib/caller.ex")
  |> Rewrite.Source.get(:content)
end

project = fn -> Igniter.Test.test_project(files: %{"lib/caller.ex" => source}) end

IO.puts("without include_all_elixir_files: " <> inspect(rename.(project.()) =~ "New.call(1)"))

IO.puts(
  "after include_all_elixir_files:   " <>
    inspect(project.() |> Igniter.include_all_elixir_files() |> rename.() =~ "New.call(1)")
)

Expected

without include_all_elixir_files: true
after include_all_elixir_files:   true

update_all_elixir_files/2 runs the updater over every included Elixir source whether or not they were included earlier; the flag only spares reading the files from disk again.

Actual

without include_all_elixir_files: true
after include_all_elixir_files:   false

MaxSvargal avatar Nov 05 '26 15:11 MaxSvargal