hrzndhrn/recode

Recode command never ends since 0.5.2

Closed this issue · 4 comments

Since version 0.5.2 mix recode command just never got finished and keeps running without providing any feedback
.recode.exs file

[
  version: "0.6.2",
  # Can also be set/reset with `--autocorrect`/`--no-autocorrect`.
  autocorrect: true,
  # With "--dry" no changes will be written to the files.
  # Can also be set/reset with `--dry`/`--no-dry`.
  # If dry is true then verbose is also active.
  dry: false,
  # Can also be set/reset with `--verbose`/`--no-verbose`.
  verbose: true,
  # Can be overwritten by calling `mix recode "lib/**/*.ex"`.
  inputs: ["{apps,config,lib,test}/**/*.{ex,exs}"],
  formatter: {Recode.Formatter, []},
  tasks: [
    # Tasks could be added by a tuple of the tasks module name and an options
    # keyword list. A task can be deactivated by `active: false`. The execution of
    # a deactivated task can be forced by calling `mix recode --task ModuleName`.
    {Recode.Task.AliasExpansion, []},
    {Recode.Task.AliasOrder, []},
    {Recode.Task.Dbg, [autocorrect: false]},
    {Recode.Task.EnforceLineLength, [active: true]},
    {Recode.Task.FilterCount, []},
    {Recode.Task.IOInspect, [autocorrect: false]},
    {Recode.Task.Nesting, []},
    {Recode.Task.PipeFunOne, []},
    {Recode.Task.SinglePipe, []},
    {Recode.Task.Specs, [exclude: "test/**/*.{ex,exs}", config: [only: :visible]]},
    {Recode.Task.TagFIXME, [exit_code: 2]},
    {Recode.Task.TagTODO, [exit_code: 4]},
    {Recode.Task.TestFileExt, []},
    {Recode.Task.UnusedVariable, [active: false]}
  ]
]

If I comment out

{Recode.Task.AliasOrder, []},
{Recode.Task.EnforceLineLength, [active: true]}

it works well.
Not sure how I get can more info for debuging

I will have a look. Thanks for reporting.

Hi, @Kitton. I assume there is an AST that makes recode some problems. It always takes effort to figure out such scenarios. It would be great if you could run recode with the source from PR #74 by adding

{:recode, github: "hrzndhrn/recode", branch: "fix/issue-73"}

to your mix.exs deps. The PR adds the --debug switch to show which task/file combination is running. You can also run recode with one task using -t like

mix recode -t AliasOrder --debug`

Thanks @NickNeck! It looks like for AliasOrder the issue was a duplicated module in the list of aliases - so it's easy to fix manually, not sure why this issue started to appear though.

With EnforceLineLength it's more interesting, for example, such code

defmodule TestModule do
  defp send_to_api(list_of_establishment_types, andjaro_token) do
    list_of_establishment_types
    |> Enum.map(fn establishment_type ->
      Common.do_request_with_entity(establishment_type, fn et ->
        ApiEstablishmentTypes.upsert_establishment_type(andjaro_token, et)
      end)
    end)
  end
end

leads to a never-ending run with recode

Thanks a lot for your debugging help. I have found the bug. The problem is the Recode.FormatterPlugin, also triggered by mix recode. Everything runs as expected without the Recode.FormatterPlugin in .formatter.exs.
I will fix it this weekend and release a new version.