hauleth

hauleth

Mix unused - simple task for looking for unused public functions

After request in this thread I created simple task for looking for unused public functions (mix xref unreachable returns information only about unused private functions).

Code: https://github.com/hauleth/mix_unused

Currently it isn’t released on Hex as I am still polishing the edges. Feel free to test this out.

Most Liked

hauleth

hauleth

So I have finally find some time to make it work for Elixir 1.10 and publish it on Hex.

Now it is implemented via compiler tracing, so it is only Elixir 1.10 and later, but thanks to that, it also works with ElixirLS.

Beware that it is still WIP, and there are some features missing, and it will print a lot (and by a lot I mean A LOT) of false positives as it do not filter out generated functions nor Elixir macros. So prepare for filtering out quite a lot.

Testers, suggestions, and pull requests are welcome.

What is not currently working:

  • Macros filtering
  • Generated functions filtering (so for example you need to filter out {:_, :__schema__, :_} if you use Ecto, all controller actions if you use Phoenix, etc.)
  • Lines for given functions, so all missing functions will be reported on top of the file
  • No way to filter out functions using regular expression
  • No way to filter out functions using range arity
12
Post #3
hauleth

hauleth

v0.4.1 released

The main reason for that is that older version was reporting false positives (used function reported as unused) if there was a call cycle.

Bug Fixes

  • resolve issue with unused analyzer reporting false positives (3b86630)

Documentation

  • Improve Usage Docs a bit around usage (a191c46)
10
Post #7
hauleth

hauleth

Release v0.2.0

Added few useful features:

  • macros are supported now
  • you can filter out functions and modules using regular expressions
  • you can filter arity using ranges
  • lines are properly supported, which mean that ElixirLS will report unused functions as a lens in correct places
hauleth

hauleth

Forgot to post it there:

v0.3.0 released

Most important change is check whether structures are used and will inform if not. Just pattern matching on the structure is enough to mark it as used.

From minor changes - it now do not fail on recompilation via Phoenix LiveReload or call to recompile/0 from IEx shell.

hauleth

hauleth

v0.4.0 released

Bug Fixes

  • do not fail if cannot write manifest (5f407c1)

Documentation

  • add documentation about using predicate filters (1360fd5)
  • misc doc changes (05c96f5)

Features

  • extract functions metadata to separate file (4cf981d)
  • add possibility to filter using metadata of the entry (9fa8838)
  • add support for unary functions in filters (684007e)
  • scan for transitive unused functions (80825bd)
  • add sponsoring link to the Hex package links (291c914)
  • add analyzer to detect functions called only recursively (48411d1)
  • add covertool support (cf476e8)
  • cleanup analyzers (5b79d32)
  • add analyzer for functions that could be private (c0bf50d)

Where Next?

Popular in Libraries Top

devonestes
Introducing assertions, the library that helps you write really great test assertions! GitHub: https://github.com/devonestes/assertions ...
New
kevinlang
Hey all, We have made an Ecto3 Adapter for SQLite3, ecto_sqlite3! We have successfully on-boarded the full suite of integration tests (...
New
sabiwara
Dune is a sandbox for Elixir and aims to safely evaluate user-provided code. You can try it out using this basic Elixir playground made ...
New
josevalim
EDIT: since Ecto 3.0 final version is out, this post was amended to use the final versions in the instructions below. Hi everyone, We a...
New
New
danschultzer
In short Plug n’ play OAuth 2.0 provider library. Just set up a resource owner schema with Ecto (your user schema), install the dependen...
New
martinthenth
Hello everybody :wave: Recently, some of my colleagues talked about database ids and uuids and their problems, and I remembered the pain...
New
Qqwy
Hello everyone, I wrote a small library today called MapDiff. It returns a map listing the (smallest amount of) changes to get from map...
New
Eiji
ExApi is a library that I’m developing now and hope release soon This library will allow to: list all apis list all api implementation...
New
vic
Expat is a tiny experiment I did for extracting patterns and being able to reuse them (compose and share patterns between elixir librarie...
New

Other popular topics Top

dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New

Sub Categories:

We're in Beta

About us Mission Statement