karolsluszniak / ex_check

One task to efficiently run all code analysis & testing tools in an Elixir project. Born out of 💜 to Elixir and pragmatism.
https://hex.pm/packages/ex_check
MIT License
305 stars 11 forks source link

Fix file detection paths in Elixir 1.16 #42

Closed ypconstante closed 4 months ago

ypconstante commented 8 months ago

In Elixir 1.16 the file detection paths have an additional ../ in front, causing the detection to fail.

This PR fixes this by changing from Path.relative_to(".") to Path.relative_to_cwd().

find_failed_detection before

[(ex_check 0.15.0) lib/ex_check/check/compiler.ex:162: ExCheck.Check.Compiler.find_failed_detection/2]
...
|> Keyword.get(:detect, []) #=> [file: "test"]
|> Enum.map(&split_detection_opts/1) #=> [{{:file, "test"}, []}]
|> Enum.map(fn {base, opts} -> {prepare_detection_base(base, name, tool_opts), opts} end) #=> [{{:file, "../test"}, []}]
|> Enum.find(fn {base, _} -> failed_detection?(base) end) #=> {{:file, "../test"}, []}

...

[(ex_check 0.15.0) lib/ex_check/check/compiler.ex:162: ExCheck.Check.Compiler.find_failed_detection/2]
...
|> Keyword.get(:detect, []) #=> [file: ".formatter.exs"]
|> Enum.map(&split_detection_opts/1) #=> [{{:file, ".formatter.exs"}, []}]
|> Enum.map(fn {base, opts} -> {prepare_detection_base(base, name, tool_opts), opts} end) #=> [{{:file, "../.formatter.exs"}, []}]
|> Enum.find(fn {base, _} -> failed_detection?(base) end) #=> {{:file, "../.formatter.exs"}, []}

find_failed_detection after

[(ex_check 0.15.0) lib/ex_check/check/compiler.ex:162: ExCheck.Check.Compiler.find_failed_detection/2]
...
|> Keyword.get(:detect, []) #=> [file: "test"]
|> Enum.map(&split_detection_opts/1) #=> [{{:file, "test"}, []}]
|> Enum.map(fn {base, opts} -> {prepare_detection_base(base, name, tool_opts), opts} end) #=> [{{:file, "test"}, []}]
|> Enum.find(fn {base, _} -> failed_detection?(base) end) #=> nil

...

[(ex_check 0.15.0) lib/ex_check/check/compiler.ex:162: ExCheck.Check.Compiler.find_failed_detection/2]
...
|> Keyword.get(:detect, []) #=> [file: ".formatter.exs"]
|> Enum.map(&split_detection_opts/1) #=> [{{:file, ".formatter.exs"}, []}]
|> Enum.map(fn {base, opts} -> {prepare_detection_base(base, name, tool_opts), opts} end) #=> [{{:file, ".formatter.exs"}, []}]
|> Enum.find(fn {base, _} -> failed_detection?(base) end) #=> nil

Fixes #41

ypconstante commented 5 months ago

@karolsluszniak can you check this PR, now that Elixir 1.16 got released?

karolsluszniak commented 4 months ago

Sorry for the delay & thank you for the fix!