Fl4m3Ph03n1x
Does anyone use Mix xref?
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 compiletask 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 !
Most Liked
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.
webuhu
I was using mix xref within CI.
In detail:
mix xref unreachable --abort-if-anymix 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
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.
Popular in Discussions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









