amacgregor

amacgregor

Is there any tooling or recommended way to find dead code? As my application starts to grow things can get a little messy especially with autogenerated contexts in phoenix.

GitHub - hauleth/mix_unused: Find unused functions in your project · GitHub is kinda what I was looking for but it seems is no longer working nor maintained.

Thanks in advance! :smiley:

Showing Posts 1 to 10

egze

egze

Doesn’t the compiler warn you about unused functions? Have you looked into it?

dmitrykleymenov

dmitrykleymenov

As far as i know, dialyzer — OTP 29.0.2 (dialyzer 6.0.1) does that.

Dialyzer is a static analysis tool that identifies software discrepancies, such as definite type errors, code that has become dead or unreachable because of programming error, and unnecessary tests, in single Erlang modules or entire (sets of) applications.

Seems like exactly what you need.

Marcus

Marcus

The compiler gives you a warning for unreachable functions. That means private functions which are not called in the module where these are defined are throwing such warnings. But public functions that are never called anywhere are not checked by the compiler.

amacgregor

amacgregor OP

Exactly I’m trying to figure out a way to check for unused public functions

Marcus

Marcus

I think @hauleth can say something about the state of :mix_unused. Or he will be except a PR from you, if you need some changes in the lib.

hauleth

hauleth

I am (very) slowly working on that one to work with compiler tracer. I can push my branch (I thought it is pushed) where I am trying to implement such and if you have any PR then it will be more than welcome.

amacgregor

amacgregor OP

That would be awesome, more than happy to help if I can.

mpope

mpope

You might also be able to use Erlang’s Xref in a Mix Task. It has options:

locals_not_used(*)
    Returns a list of local functions that have not been locally used.
exports_not_used
    Returns a list of exported functions that have not been externally used. Note that in modules mode, M:behaviour_info/1 is never reported as unused. 
hauleth

hauleth

This will return a lot of false positives due to macros and other autogenerated functions in Elixir.

mpope

mpope

Makes sense, I’ve only used it in Erlang projects.

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
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
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
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

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews