Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hauleth/mix_unused
Find unused functions in your project
https://github.com/hauleth/mix_unused
elixir elixir-lang hacktoberfest mix unused
Last synced: 1 day ago
JSON representation
Find unused functions in your project
- Host: GitHub
- URL: https://github.com/hauleth/mix_unused
- Owner: hauleth
- License: mit
- Created: 2019-01-04T16:50:01.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-12-26T21:13:55.000Z (about 1 year ago)
- Last Synced: 2025-02-12T11:08:28.399Z (8 days ago)
- Topics: elixir, elixir-lang, hacktoberfest, mix, unused
- Language: Elixir
- Homepage:
- Size: 146 KB
- Stars: 220
- Watchers: 5
- Forks: 13
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Mix Unused
[](https://hex.pm/packages/mix_unused)
[](https://hexdocs.pm/mix_unused/)
[](https://hex.pm/packages/mix_unused)
[](https://github.com/hauleth/mix_unused/blob/master/LICENSE.md)
[](https://github.com/hauleth/mix_unused/commits/master)
[](https://codecov.io/gh/hauleth/mix_unused)Mix compiler tracer for detecting unused public functions.
## Installation
```elixir
def deps do
[
{:mix_unused, "~> 0.3.0"}
]
end
```The docs can be found at [https://hexdocs.pm/mix_unused](https://hexdocs.pm/mix_unused).
## Usage
After installation you need to add `:unused` as a compiler to the list of Mix
compilers:```elixir
defmodule MySystem.MixProject do
use Mix.Projectdef project do
[
compilers: [:unused] ++ Mix.compilers(),
# In case of Phoenix projects you need to add it to the list
# compilers: [:unused, :phoenix, :gettext] ++ Mix.compilers()
# ...
#
# If you want to only run it in the dev environment you could do
# it by using `compilers: compilers(Mix.env()) ++ Mix.compilers()`
# instead and then returning the right compilers per environment.
]
end# ...
end
```Then you just need to run `mix compile` or `mix compile --force` as usual
and unused hints will be added to the end of the output.### Warning
This isn't perfect solution and this will not find dynamic calls in form of:
```elixir
apply(mod, func, args)
```So this mean that, for example, if you have custom `child_spec/1` definition
then `mix unused` can return such function as unused even when you are using
that indirectly in your supervisor.### Configuration
You can define used functions by adding `mfa` in `unused: [ignored: [⋯]]`
in your project configuration:```elixir
def project do
[
# ⋯
unused: [
ignore: [
{MyApp.Foo, :child_spec, 1}
]
],
# ⋯
]
end
```## Copyright and License
Copyright © 2021 by Łukasz Niemier
This work is free. You can redistribute it and/or modify it under the
terms of the MIT License. See the [LICENSE](./LICENSE) file for more details.