Skip to content

Commit

Permalink
chore: prepare first release
Browse files Browse the repository at this point in the history
  • Loading branch information
hauleth committed Aug 28, 2021
1 parent 4e74480 commit 05efe16
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 25 deletions.
56 changes: 35 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Mix Unused

Simple `mix` task that list all unused public functions in your project.
Mix compiler tracer for detecting unused public functions.

## Installation

Expand All @@ -21,14 +21,33 @@ be found at [https://hexdocs.pm/mix_unused](https://hexdocs.pm/mix_unused).

## Usage

Install and run `mix unused` and you will get list of all unused public
functions.
After installation you need to add `:unused` as a compiler to the list of Mix
compilers:

```elixir
defmodule MySystem.MixProject do
use Mix.Project

def 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()
# ...
]
end

# ...
end
```

### Warning

This isn't perfect solution and this will not find dynamic calls in form of:

apply(mod, func, args)
```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
Expand All @@ -39,24 +58,19 @@ that indirectly in your supervisor.
You can define used functions by adding `mfa` in `unused: [ignored: [⋯]]`
in your project configuration:

def project do
[
# ⋯
unused: [
ignore: [
{MyApp.Foo, :child_spec, 1}
]
],
# ⋯
```elixir
def project do
[
#
unused: [
ignore: [
{MyApp.Foo, :child_spec, 1}
]
end

## Options

- `--exit-status` (default: false) - returns 1 if there are any unused function
calls
- `--quiet` (default: false) - do not print output
- `--compile` (default: true) - compile project before running
],
#
]
end
```

# License

Expand Down
2 changes: 2 additions & 0 deletions lib/mix_unused/tracer.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
defmodule MixUnused.Tracer do
@moduledoc false

use GenServer

@tab __MODULE__.Functions
Expand Down
17 changes: 13 additions & 4 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,21 @@ defmodule MixUnused.MixProject do
def project do
[
app: :mix_unused,
description: "Mix compiler tracer for detecting unused public functions",
version: "0.1.0",
elixir: "~> 1.10",
deps: deps()
package: [
licenses: ~w[MPL-2.0],
links: %{
"GitHub" => "https://github.com/hauleth/mix_unused"
}
],
deps: [
{:ex_doc, ">= 0.0.0", only: :dev}
],
docs: [
main: "Mix.Tasks.Compile.Unused"
]
]
end

Expand All @@ -16,7 +28,4 @@ defmodule MixUnused.MixProject do
extra_applications: [:mix, :logger]
]
end

# Run "mix help deps" to learn about dependencies.
defp deps, do: []
end
8 changes: 8 additions & 0 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
%{
"earmark_parser": {:hex, :earmark_parser, "1.4.15", "b29e8e729f4aa4a00436580dcc2c9c5c51890613457c193cc8525c388ccb2f06", [:mix], [], "hexpm", "044523d6438ea19c1b8ec877ec221b008661d3c27e3b848f4c879f500421ca5c"},
"ex_doc": {:hex, :ex_doc, "0.25.1", "4b736fa38dc76488a937e5ef2944f5474f3eff921de771b25371345a8dc810bc", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "3200b0a69ddb2028365281fbef3753ea9e728683863d8cdaa96580925c891f67"},
"makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
"makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"},
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
"nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"},
}

0 comments on commit 05efe16

Please sign in to comment.