Fl4m3Ph03n1x

Fl4m3Ph03n1x OP

Background

Recently I found out aboubt mix xref, which according to my understanding analyses the code for unreachable paths and deprecated functions.

Questions

It looks really nice, but I have some questions:

  • Isn’t this already part of the mix compile task that runs automatically every time you execute a non-compiled project?
  • In which scenarios do I have to manually run this command?
  • Do you guys use it in your CIs ?

Please let me know your answers !

First 7 of 7 Posts Switch mode

hauleth

hauleth

mix xref was useful not only for finding unreachable code, it also supported looking for all callers or generating dependency graph of the application. So none of these functionalities was available during compilation.

Fl4m3Ph03n1x

Fl4m3Ph03n1x OP

But do you use it on a daily basis?

NobbZ

NobbZ

Do you use mix test --stale? If yes, you are using mix xref more than you might know that you use it.

Similar if you use the ElixirLS. It builds upon xrefs result asas well.

hauleth

hauleth

Do you use dbg module on daily basis? Do you use mix profile.* on daily basis? No, these tools have specific use cases, and when you need them you praise all J’s that decided that it should be part of the default release instead of spending X hours on searching solutions that will work.

webuhu

webuhu

I was using mix xref within CI.

In detail:

  • mix xref unreachable --abort-if-any
  • mix xref deprecated --abort-if-any

But as with Elixir v1.10 these checks will move into the compiler.
I will use instead:

  • mix compile --warnings-as-errors
dimitarvp

dimitarvp

I’m currently using mix xref callers MyApp.Schema – a module namespace that contains all my DB (Ecto) code. I’m integrating it in a GIT pre-commit hook that checks which modules use that namespace because I only want certain modules to directly use DB code.

So that’s one valid usage: you can enforce some limitations on your project at GIT pre-commit or CI server level. You can call it homemade linting.

Another very good usage is refactoring. When you move functions around – or rename them, or delete them – you want to minimise compilation or runtime errors so you first search who calls them and rework those as well along the way.

lawik

lawik

Nerves Core Team

Saw the command thanks to the coming changes and ended up needing mix xref callers MyModule.function/1 to refactor things in a client project.

— All posts loaded —

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 91898 914
New
AstonJ
The obligatory hello world thread! Who are you and where are you from? :stuck_out_tongue:
4616 55835 594
New
byu
@chrismccord : I just saw the Extract AGENTS.md from Phoenix.new into phx.new generator commit to the phoenix project. My initial shotgu...
New
arcanemachine
I was working on an Ecto migration and I needed a timestamp. So, for the nth time, I looked up the different data types for timestamps, a...
New
AstonJ
Just a general thread to post chat/news/info relating to AI/ML stuff that may be relevant for Nx now or in the future. Got anything to sh...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
mudasobwa
While I am working on the Language Agnostic Code Audit SaaS, which uses MetaAST (spoiler: I am expecting it to be in a good shape for ann...
New

We're in Beta

About us Mission Statement