From 5d8d2e80a5a1e11824709059a02dbf5320e0a876 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 5 Oct 2021 15:29:23 +0200 Subject: [PATCH] Add mix_unused to detect unused functions Signed-off-by: Thomas Citharel --- mix.exs | 43 +++++++++++++++++++++++++++++++++++++++++-- mix.lock | 1 + 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/mix.exs b/mix.exs index 22eb1685..c4693fc4 100644 --- a/mix.exs +++ b/mix.exs @@ -9,7 +9,7 @@ defmodule Mobilizon.Mixfile do version: @version, elixir: "~> 1.11", elixirc_paths: elixirc_paths(Mix.env()), - compilers: [:gettext] ++ Mix.compilers(), + compilers: [:gettext, :unused] ++ Mix.compilers(), xref: [exclude: [:eldap]], start_permanent: Mix.env() == :prod, aliases: aliases(), @@ -37,6 +37,44 @@ defmodule Mobilizon.Mixfile do config_providers: [{Mobilizon.ConfigProvider, "/etc/mobilizon/config.exs"}], steps: [:assemble, ©_files/1, ©_config/1] ] + ], + unused: [ + ignore: [ + Mobilizon.Storage.Repo, + Mobilizon.Storage.PostgresTypes, + Mobilizon.Factory, + Mobilizon.Web.Router.Helpers, + Mobilizon.Web.Email.Mailer, + Mobilizon.Web.Auth.Guardian.Plug, + Mobilizon.Web.Gettext, + Mobilizon.Web.Endpoint, + Mobilizon.Web.Auth.Guardian, + Mobilizon.Web, + Mobilizon.GraphQL.Schema.Compiled, + Mobilizon.GraphQL.Schema, + Mobilizon.Web.Router, + Mobilizon.Users.Setting.Location, + {:_, :start_link, 1}, + {:_, :child_spec, 1}, + {:_, :__impl__, 1}, + {:_, :__schema__, :_}, + {:_, :__struct__, 0..1}, + {:_, :__changeset__, 0}, + {:_, :create_type, 0}, + {:_, :drop_type, 0}, + {:_, :schema, 0}, + {:_, :schemaless_type, 0}, + {:_, :valid_value?, 0..1}, + {:_, :__enum_map__, 0}, + {:_, :__absinthe_blueprint__, :_}, + {:_, :__absinthe_function__, :_}, + {~r/^Mobilizon.Web.*Controller/, :_, 2}, + {~r/^Mobilizon.Web.*View/, :_, :_}, + {~r/^Mobilizon.Web.Email.*/, :render, 3}, + {~r/^Mobilizon.Service.HTTP.*Client/, :_, :_}, + {~r/^Mobilizon.Cldr.*/, :_, :_}, + {Mobilizon.Web.GraphQLSocket, :__channel__, 1} + ] ] ] end @@ -183,7 +221,8 @@ defmodule Mobilizon.Mixfile do {:mox, "~> 1.0", only: :test}, {:junit_formatter, "~> 3.1", only: [:test]}, {:sobelow, "~> 0.8", only: [:dev, :test]}, - {:doctor, "~> 0.18.0", only: :dev} + {:doctor, "~> 0.18.0", only: :dev}, + {:mix_unused, "~> 0.2.0"} ] ++ oauth_deps() end diff --git a/mix.lock b/mix.lock index c6e1bddd..6b3969f4 100644 --- a/mix.lock +++ b/mix.lock @@ -94,6 +94,7 @@ "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"}, "mimetype_parser": {:hex, :mimetype_parser, "0.1.3", "628ac9fe56aa7edcedb534d68397dd66674ab82493c8ebe39acb9a19b666099d", [:mix], [], "hexpm", "7d8f80c567807ce78cd93c938e7f4b0a20b1aaaaab914bf286f68457d9f7a852"}, "mix_test_watch": {:hex, :mix_test_watch, "1.1.0", "330bb91c8ed271fe408c42d07e0773340a7938d8a0d281d57a14243eae9dc8c3", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}], "hexpm", "52b6b1c476cbb70fd899ca5394506482f12e5f6b0d6acff9df95c7f1e0812ec3"}, + "mix_unused": {:hex, :mix_unused, "0.2.0", "430d011f7c86eec8e4824c66fb69127f192ca3b2b2dd0e0f8f58bf535d319167", [:mix], [], "hexpm", "f3eb53bf416d89be1db801865b3f2a6c8c084e138ad290c82b5136a31e5622ad"}, "mmdb2_decoder": {:hex, :mmdb2_decoder, "3.0.0", "54828676a36e75e9a25bc9a0bb0598d4c7fcc767bf0b40674850b22e05b7b6cc", [:mix], [], "hexpm", "359dc9242915538d1dceb9f6d96c72201dca76ce62e49d22e2ed1e86f20bea8e"}, "mock": {:hex, :mock, "0.3.7", "75b3bbf1466d7e486ea2052a73c6e062c6256fb429d6797999ab02fa32f29e03", [:mix], [{:meck, "~> 0.9.2", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm", "4da49a4609e41fd99b7836945c26f373623ea968cfb6282742bcb94440cf7e5c"}, "mogrify": {:hex, :mogrify, "0.9.1", "a26f107c4987477769f272bd0f7e3ac4b7b75b11ba597fd001b877beffa9c068", [:mix], [], "hexpm", "134edf189337d2125c0948bf0c228fdeef975c594317452d536224069a5b7f05"},