The release of Elixir v1.3 added a mix task called
xref for performing cross reference checks of your code.
mix xref gives us some handy tools!
Find unreachable code:
❯ mix xref unreachable lib/exonk8s/foo.ex:16: SomeModule.non_existant/0
Find callers of modules and functions:
❯ mix xref callers SomeModule lib/exonk8s/foo.ex:16: SomeModule.non_existant/0
Generate a dependency graph:
> mix xref graph lib/exonk8s.ex ├── lib/exonk8s/repo.ex └── lib/router.ex └── lib/exonk8s/musician_controller.ex (compile) ├── lib/exonk8s/foo.ex ├── lib/exonk8s/musician.ex └── lib/exonk8s/repo.ex ...snipped for brevity
The release of Elixir v1.6 added the module attribute
@deprecated to enable library authors to warn users of deprecated functions.
❯ mix xref deprecated Compiling 2 files (.ex) Foo Loaded warning: ExOnK8s.Foo.lazy/0 is deprecated. You should be more eager. lib/exonk8s/musician_controller.ex:10 lib/exonk8s/musician_controller.ex:10: ExOnK8s.Foo.lazy/0
Lastly I should note that
xref deprecated and
xref unreachable are included in the compiler warnings, so you you’ve likely seen these at work even if you didn’t know they were there.